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 the one depending on mock sequencingPolicy. By default it means most recent one.
Declaration
Swift
public func Given<T>(_ object: T, _ method: T.Given, _ policy: StubbingPolicy = .default) where T : MockParameters
objectMock instance
methodMethod signature with wrapped parameters (Parameter
) and return value policyStubbing policy - uses mock policy by default (which defaults to .wrap)
-
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 the one depending on mock sequencingPolicy. By default it means most recent one.
Declaration
Swift
public func Perform<T>(_ object: T, _ method: T.Perform) where T : MockParameters
objectMock instance
methodMethod 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>(_ object: T, _ method: T.Verify, file: StaticString = #file, line: UInt = #line) where T : MockParameters
objectMock instance
methodMethod signature with wrapped parameters (
Parameter)filefor XCTest print purposes
linefor XCTest print purposes
-
Verify that given method was called on mock object exact number of times.
Declaration
Parameters
objectMock instance
countNumber of invocations
methodMethod signature with wrapped parameters (
Parameter)filefor XCTest print purposes
linefor XCTest print purposes
View on GitHub
Global methods Reference