lundi 28 septembre 2015

XCTest test for not happening before timeout

I found a lot of questions about how to write a unit test that tests whether something happens before a timeout, using something like

- (void)waitForExpectationsWithTimeout:(NSTimeInterval)timeout handler:(nullable XCWaitCompletionHandler)handler;

but are there any ways to test for "Make sure X does not get called within Y seconds" ?

Our current approach was something like:

[[NSRunLoop currentRunLoop] runUntilDate:<short before timeout>]

and afterwards check that the block never got called.

Unfortunately since XCode 7 the outcome of these tests has become very non-deterministic... is there a better way to test this?

Aucun commentaire:

Enregistrer un commentaire