Class
ArgumentCaptor
public class ArgumentCaptor<ParameterType>: ArgumentMatcher
Captures method arguments passed during mock invocations.
An argument captor extracts received argument values which can be used in other parts of the test.
let bird = mock(Bird.self)
bird.name = "Ryan"
let nameCaptor = ArgumentCaptor<String>()
verify(bird.setName(nameCaptor.matcher)).wasCalled()
print(nameCaptor.value) // Prints "Ryan"
Relationships
Superclass
ArgumentMatcher
Matches argument values with a comparator.
Initializers
init(weak:)
public init(weak: Bool = false)
Create a new argument captor.
Parameters
Name | Type | Description |
---|---|---|
weak | Bool |
Whether captured arguments should be stored weakly. |
Properties
matcher
var matcher: ParameterType
Passed as a parameter to mock verification contexts.
allValues
var allValues: [ParameterType]
All recorded argument values.
value
var value: ParameterType?
The last recorded argument value.