Instance Method

expectation(description:)

Creates a new expectation with an associated description.

Declaration

func expectation(description: String) -> XCTestExpectation

Parameters

description

A string to display in the test log for this expectation, to help diagnose failures.

Discussion

Use this method to create XCTestExpectation instances that can be fulfilled when asynchronous tasks in your tests complete.

To fulfill an expectation that was created with expectation(description:), call the expectation's fulfill() method when the asynchronous task in your test has completed.

See Also

Creating Asynchronous Test Expectations

func expectation(for: NSPredicate, evaluatedWith: Any?, handler: XCTNSPredicateExpectation.Handler?) -> XCTestExpectation

Creates an expectation that is fulfilled if the predicate returns true when evaluated with the given object.

func keyValueObservingExpectation(for: Any, keyPath: String, expectedValue: Any?) -> XCTestExpectation

Creates an expectation that uses Key Value Observing to observe a value until it matches an expected value.

func keyValueObservingExpectation(for: Any, keyPath: String, handler: XCTKVOExpectation.Handler?) -> XCTestExpectation

Creates an expectation that uses Key Value Observing to observe a value and respond to changes in that value by calling a provided handler.