delegate のテストなどに役立つ。
テストメソッドの最後に Async を付け、非同期でよびだされる側のメソッドにテストコードと STSuccess()を書いておく。
- (void)testSelectorAsync { [self performSelector:@selector(myOtherSelector:) withObject:@(2) afterDelay:2.0]; } - (void)myOtherSelector:(NSNumber *)value { STAssertEqualObjects(value, @(3), @"Expecting the number '3'."); STSuccess(); }
追加されたマクロ
STFailAfter(timeout, description, …): This macro starts a timer and let the test fail with the given description, if nothing else (STAssert… or STSuccess) has been called.
STSuccess(): This macro has to be called to indicate that the test did succeed. If this won't be called and no other failure occured, the test runs forever.