Instance Method

expectationForPredicate:evaluatedWithObject:handler:

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

Declaration

- (XCTestExpectation *)expectationForPredicate:(NSPredicate *)predicate evaluatedWithObject:(id)object handler:(XCPredicateExpectationHandler)handler;

Parameters

predicate

The predicate to evaluate.

object

The object against which the predicate is evaluated.

handler

An optional handler that performs custom evaluation when predicate evaluates as YES.

Discussion

The expectation periodically evaluates the predicate and also may use notifications or other events to optimistically re-evaluate.

If a handler is not provided, the first successful evaluation of the predicate will fulfill the expectation. If a handler is provided, the handler can override this default behavior and tailor the conditions under which the expectation should be considered fulfilled.

See Also

Creating Asynchronous Test Expectations

expectationWithDescription:

Creates a new expectation with an associated description.

expectationForNotification:object:handler:

Creates an expectation that is fulfilled when a specific NSNotification is received for a given object.

keyValueObservingExpectationForObject:keyPath:expectedValue:

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

keyValueObservingExpectationForObject:keyPath:handler:

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