Mockingbird Documentation 0.17.0

Class Argument​Captor

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"
ArgumentCaptor ArgumentCaptor ArgumentMatcher ArgumentMatcher ArgumentCaptor->ArgumentMatcher

Superclass

ArgumentMatcher

Matches argument values with a comparator.

Initializers

init(weak:​)

public init(weak: Bool = false)  

Create a new argument captor.

Parameters

weak Bool

Whether captured arguments should be stored weakly.

Properties

matcher

public var matcher: ParameterType  

Passed as a parameter to mock verification contexts.

all​Values

public var allValues: [ParameterType]  

All recorded argument values.

value

public var value: ParameterType?  

The last recorded argument value.