I'm looking for something that uses XCTextExpectation in the setup or teardown methods. In Objective-C, it would look something like this:
- (void)setUp {
XCTestExpectation *getUserAsyncComplete = [self expectationWithDescription:@"Get Request Attempted and Finished"];
[Connection loginWithEmail:@"[email protected]" onSuccess:^void(^) {
[getUserAsyncComplete fulfill];
} onError:nil;
[self waitForExpectationsWithTimeout:[self.timeLimit doubleValue] handler:^(NSError *error) {
if (error != nil) {
XCTFail(@"Failure: user retrieval exceeded %f seconds.", [self.timeLimit doubleValue]);
}
}];
}
I've tried this code and it doesn't seem to be working; either that could be because Xcode 6 is still in beta, or it's not supported. Even if there is a solution in Swift, that would be greatly appreciated.
You mistyped the method name, this seems to work just fine (Xcode 6, beta 2)
- (void)setUp {
[super setUp];
XCTestExpectation *exp = [self expectationWithDescription:@"Login"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(29 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[exp fulfill];
});
[self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {
// handle failure
}];
}
- (void)testExample {
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With