As per the discussion in comments we found that waitUntilFinished
is once the background operation is complete, and it does not wait till after the completion blocks have been called.
There's a much better framework for asynchronous testing - Expecta.
Then instead of calling:
XCTAssertTrue(req.isFinished);
XCTAssertEqual([[resObj objectForKey:@"success"] boolValue], YES);
You can do:
expect(req.isFinished).will.beTruthy();
expect([[resObj objectForKey:@"success"] boolValue]).will.beTruthy();
There are lots of other matchers, just make sure you set the timeout with +[Expecta setAsynchronousTestTimeout:]
in your +setUp
method.