Mockingbird Documentation 0.18.0

Function sequence(of:​)

public func sequence<DeclarationType: Declaration, InvocationType, ReturnType>(
  of implementations: InvocationType...
) -> ImplementationProvider<DeclarationType, InvocationType, ReturnType>  

Stub a sequence of implementations.

Provide one or more implementations which will be returned sequentially for each invocation. The last implementation will be used if the number of invocations is greater than the number of implementations provided.

given(bird.name).willReturn(sequence(of: {
  return Bool.random() ? "Ryan" : "Meisters"
}, {
  return Bool.random() ? "Sterling" : "Hackley"
}))

print(bird.name)  // Prints "Ryan"
print(bird.name)  // Prints "Sterling"
print(bird.name)  // Prints "Hackley"

Parameters

implementations Invocation​Type

A sequence of implementations to stub.