Mockingbird Documentation 0.14.0

Function eventually(_:​_:​)

public func eventually(_ description: String? = nil, _ block: () -> Void) -> XCTestExpectation

Create a deferrable test expectation from a block containing verification calls.

Mocked methods that are invoked asynchronously can be verified using an eventually block which returns an XCTestExpectation.

DispatchQueue.main.async {
  Tree(with: bird).shake()
}

let expectation =
  eventually {
    verify(bird.fly()).wasCalled()
    verify(bird.chirp()).wasCalled()
  }

wait(for: [expectation], timeout: 1.0)

Parameters

description String?

An optional description for the created XCTestExpectation.

block () -> Void

A block containing verification calls.

Returns

An XCTestExpectation that fulfilles once all verifications in the block are met.