TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
This library is wrapper for ishkawa/NSRunLoop-PerformBlock.
You can write async testcase by Mocha's done
style.
@interface ExampleTests : XCTestCase
@end
@implementation ExampleTests
- (void)testExample{
[self runAsyncWithBlock:^(AsyncDone done) {
// async function
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_after(popTime, queue, ^(void){
done();// => done async test
});
}];
}
@end
typedef void(^AsyncDone)();
@interface XCTestCase (RunAsync)
- (void)runAsyncWithBlock:(void (^)(AsyncDone done)) runTestCode;
- (void)runAsyncWithBlock:(void (^)(AsyncDone done)) runTestCode timeout:(NSTimeInterval) timeout;
@end
XCTestCase+RunAsync is available under the MIT license. See the LICENSE file for more info.