I'd like to write black-box unit tests for a method that calls another one with a delay. It kinda looks like this:
- (void) doSomething {
// Do something
[self performSelector:@selector(doSomethingLater) withObject:nil afterDelay:kDelay];
}
- (void) doSomethingLater { }
Where kDelay
is a constant and doSomethingLater
is private. The problem is that kDelay
is 1 second and I don't want to slow down the execution of unit tests.
What would be the best way to unit test doSomething
under a black-box approach (or as much as possible)?
The only thing that comes to mind is to add a method to the class to change the value of kDelay
, but this could be used by accident by another developer. Is there a less invasive alternative?