OK I looked around and did not find the exact answer to my question.
I am trying to check the timeout handler in unit test (and not on the main run).
The problem is that [NSRunLoop mainRunLoop] does not work in unit tests the same way as in standard Run.
I do my timeouts this way:
NSTimer *pTimeoutHandler = [NSTimer timerWithTimeInterval:2.0 target:self selector:@selector(timeoutHandler:) userInfo:nil repeats:NO ]; [[NSRunLoop mainRunLoop] addTimer:pTimeoutHandler forMode:NSRunLoopCommonModes];
This works in a standard run. This is the recommended timeout setting.
However, in a test run, this does not work. The timeoutHandler:(NSTimer*)timer procedure is never called.
Something seems to be interfering with the startup cycle.
Is there a way to make the timeout work in both run and unit test?
ios unit-testing
Little green viper
source share