Other Functions
The following functions are available globally.
-
Verify that given static method was called on mock type at least once.
Declaration
Swift
public func Verify<T>(_ type: T.Type, _ method: T.StaticVerify, file: StaticString = #file, line: UInt = #line) where T : StaticMockParameters
objectMock type
methodMethod signature with wrapped parameters (
Parameter)filefor XCTest print purposes
linefor XCTest print purposes
-
Verify that given static method was called on mock type exact number of times.
Declaration
Swift
public func Verify<T>(_ type: T.Type, _ count: Count, _ method: T.StaticVerify, file: StaticString = #file, line: UInt = #line) where T : StaticMockParameters
objectMock type
countNumber of invocations
methodStatic method signature with wrapped parameters (
Parameter)filefor XCTest print purposes
linefor XCTest print purposes
-
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 the one depending on mock sequencingPolicy. By default it means most recent one.
Declaration
Swift
public func Given<T>(_ type: T.Type, _ method: T.StaticGiven, _ policy: StubbingPolicy = .default) where T : StaticMockParameters
objectMock type
methodStatic method signature with wrapped parameters (Parameter
) and return value policyStubbing policy - uses mock policy by default (which defaults to .wrap)
-
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 the one depending on mock sequencingPolicy. By default it means most recent one.
Declaration
Swift
public func Perform<T>(_ object: T.Type, _ method: T.StaticPerform) where T : StaticMockParameters
objectMock type
methodStatic method signature with wrapped parameters (Parameter
) and perform closure
View on GitHub
Other Functions Reference