XCTestCase-RunAsync 0.2.0

XCTestCase-RunAsync 0.2.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by azu, akuraru.



XCTestCase+RunAsync

This library is wrapper for ishkawa/NSRunLoop-PerformBlock.

You can write async testcase by Mocha's done style.

Usage

@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

API

typedef void(^AsyncDone)();

@interface XCTestCase (RunAsync)
- (void)runAsyncWithBlock:(void (^)(AsyncDone done)) runTestCode;

- (void)runAsyncWithBlock:(void (^)(AsyncDone done)) runTestCode timeout:(NSTimeInterval) timeout;
@end

Installation

License

XCTestCase+RunAsync is available under the MIT license. See the LICENSE file for more info.