Async testing with Xcode and any testing framework such as XCTest, SenTestingKit, Expecta, etc.

I wrote TRVSMonitor, a synchronization construct with the ability to wait until signalled that a condition was met.

This makes asynchronous testing easy. TRVSMonitor works with any testing framework too.

@interface APIClientTests : XCTestCase
@property (nonatomic, strong, readwrite) NSURLSession *URLSession;

@implementation APIClientTests

- (void)setUp {
    self.URLSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];

- (void)testAPIEndpoint {
    __block NSDictionary *JSON = nil;
    __block TRVSMonitor *monitor = [TRVSMonitor monitor];

    [self.URLSession dataTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        JSON = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
        [monitor signal];

    [monitor wait];

    XCTAssertEqualObjects(@"1", JSON[@"id"]);
    XCTAssertEqualObjects(@"travis jeffery", JSON[@"name"]);


Check the readme for the deets.