Mockingbird Documentation 0.17.0

Function looping​Sequence(of:​)

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

Stub a looping sequence of implementations.

Provide one or more implementations which will be returned sequentially for each invocation. The sequence will loop from the beginning if the number of invocations is greater than the number of implementations provided.

given(bird.getName()).willReturn(loopingSequence(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 "Meisters"
print(bird.name)  // Prints "Hackley"

Parameters

implementations Invocation​Type

A sequence of implementations to stub.