Global methods
-
Setup return value for method stubs in mock instance. When this method will be called on mock, it will check for first matching given, with following rules:
- First check most specific givens (with explicit parameters - .value), then for wildcard parameters (.any)
- More recent givens have higher priority than older ones
- When two given’s have same level of explicity, like:
Given(mock, .do(with: .value(1), and: .any) Given(mock, .do(with: .any, and: .value(1))
Method stub will return most recent one.
Declaration
Swift
public func Given<T: Mock>(_ object: T, _ method: T.Given)
Parameters
object
Mock instance
method
Method signature with wrapped parameters (Parameter
) and return value -
Setup return value for static method stubs on mock type. When this static method will be called, it will check for first matching given, with following rules:
- First check most specific givens (with explicit parameters - .value), then for wildcard parameters (.any)
- More recent givens have higher priority than older ones
- When two given’s have same level of explicity, like:
Given(T.self, .do(with: .value(1), and: .any) Given(T.self, .do(with: .any, and: .value(1))
Method stub will return most recent one.
Declaration
Swift
public func Given<T: StaticMock>(_ type: T.Type, _ method: T.StaticGiven)
Parameters
object
Mock type
method
Static method signature with wrapped parameters (Parameter
) and return value -
Setup perform closure for method stubs in mock instance. When this method will be called on mock, it will check for first matching closure and execute it with parameters passed. Have in mind following rules:
- First check most specific performs (with explicit parameters - .value), then for wildcard parameters (.any)
- More recent performs have higher priority than older ones
- When two performs have same level of explicity, like:
Perform(mock, .do(with: .value(1), and: .any, perform: { ... })) Perform(mock, .do(with: .any, and: .value(1), perform: { ... }))
Method stub will return most recent one.
Declaration
Swift
public func Perform<T: Mock>(_ object: T, _ method: T.Perform)
Parameters
object
Mock instance
method
Method signature with wrapped parameters (Parameter
) and perform closure -
Setup perform closure for static method stubs for mock type. When this method will be called on mock type, it will check for first matching closure and execute it with parameters passed. Have in mind following rules:
- First check most specific performs (with explicit parameters - .value), then for wildcard parameters (.any)
- More recent performs have higher priority than older ones
- When two performs have same level of explicity, like:
Perform(T.self, .do(with: .value(1), and: .any, perform: { ... })) Perform(T.self, .do(with: .any, and: .value(1), perform: { ... }))
Method stub will return most recent one.
Declaration
Swift
public func Perform<T: StaticMock>(_ object: T.Type, _ method: T.StaticPerform)
Parameters
object
Mock type
method
Static method signature with wrapped parameters (Parameter
) and perform closure -
Verify that given method was called on mock object at least once.
Declaration
Swift
public func Verify<T: Mock>(_ object: T, _ method: T.Verify, file: StaticString = #file, line: UInt = #line)
Parameters
object
Mock instance
method
Method signature with wrapped parameters (
Parameter
)file
for XCTest print purposes
line
for XCTest print purposes
-
Verify that given static method was called on mock type at least once.
Declaration
Swift
public func Verify<T: StaticMock>(_ type: T.Type, _ method: T.StaticVerify, file: StaticString = #file, line: UInt = #line)
Parameters
object
Mock type
method
Method signature with wrapped parameters (
Parameter
)file
for XCTest print purposes
line
for XCTest print purposes
-
Verify that given method was called on mock object exact number of times.
Declaration
Swift
public func Verify<T: Mock>(_ object: T, _ count: UInt, _ method: T.Verify, file: StaticString = #file, line: UInt = #line)
Parameters
object
Mock instance
count
Number of invocations
method
Method signature with wrapped parameters (
Parameter
)file
for XCTest print purposes
line
for XCTest print purposes
-
Verify that given static method was called on mock type exact number of times.
Declaration
Swift
public func Verify<T: StaticMock>(_ type: T.Type, _ count: UInt, _ method: T.StaticVerify, file: StaticString = #file, line: UInt = #line)
Parameters
object
Mock type
count
Number of invocations
method
Static method signature with wrapped parameters (
Parameter
)file
for XCTest print purposes
line
for XCTest print purposes