Types
-
Every generated mock implementation adopts Mock protocol. It defines base Mock structure and features.
See moreDeclaration
Swift
public protocol Mock : AnyObject
-
Every mock, that stubs static methods, should adopt StaticMock protocol. It defines base StaticMock structure and features.
See moreDeclaration
Swift
public protocol StaticMock : AnyObject
-
Parameter wraps method attribute, allowing to make a difference between explicit value, expressed by
.value
case and wildcard value, expressed by.any
case.Whole idea is to be able to test and specify behaviours, in both generic and explicit way (and any mix of these two). Every test method matches mock methods in signature, but changes attributes types to Parameter.
That allows pattern like matching between two Parameter values:
- .any is equal to every other parameter. (!!! actual case name is
._
, but it is advised to use.any
) - .value(p1) is equal to .value(p2) only, when p1 == p2
Important! Comparing parameters, where ValueType is not Equatable will result in fatalError, unless you register comparator for its ValueType in Matcher instance used (typically Matcher.default)
- any: represents and matches any parameter value
- value: represents explicit parameter value
Declaration
Swift
public enum Parameter<ValueType>
extension Parameter: ExpressibleByStringLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByUnicodeScalarLiteral where ValueType: ExpressibleByStringLiteral
extension Parameter: ExpressibleByNilLiteral where ValueType: ExpressibleByNilLiteral
extension Parameter: ExpressibleByIntegerLiteral where ValueType: ExpressibleByIntegerLiteral
extension Parameter: ExpressibleByBooleanLiteral where ValueType: ExpressibleByBooleanLiteral
extension Parameter: ExpressibleByFloatLiteral where ValueType: ExpressibleByFloatLiteral
extension Parameter: ExpressibleByArrayLiteral where ValueType: ExpressibleByArrayLiteral
extension Parameter: ExpressibleByDictionaryLiteral where ValueType: ExpressibleByDictionaryLiteral, ValueType.Key: Hashable
- .any is equal to every other parameter. (!!! actual case name is
-
Matcher is container class, responsible for storing and resolving comparators for given types.
See moreDeclaration
Swift
public class Matcher
-
Allows matching count, verifying whether given count is right or not
See moreDeclaration
Swift
public protocol Countable
-
Count enum. Use it for all Verify features, when checking how many times something happened.
There are three ways of using it:
- Explicit literal - you can pass 0, 1, 2 … to verify exact number
- Using predefined .custom, to specify custom matching rule.
- Using one of predefined rules, for example:
- .atLeastOnce
- .exactly(1)
- .from(2, to: 4)
- .less(than: 2)
- .lessOrEqual(to: 1)
- .more(than: 2)
- .moreOrEqual(to: 3)
- .never
Declaration
Swift
public enum Count : ExpressibleByIntegerLiteral
extension Count: CustomStringConvertible
extension Count: Countable
-
Used to populate stubbed method with sequence of events. Call it’s methods, to record subsequent stub return values.
See moreDeclaration
Swift
public struct Stubber<ReturnedValue>
-
Used to populate stubbed method with sequence of events. Call it’s methods, to record subsequent stub return/throw values.
See moreDeclaration
Swift
public struct StubberThrows<ReturnedValue>