Testing Asynchronous Events In Cocoa Unit Tests
I was scratching my head trying to figure out how to unit test NSURLConnection when the Google God gave me this explanation from Mitchell Hashimoto.
Since the operation under test is asynchronous, the test would exit before the the NSURLConnection completed. The key is to let an NSRunLoop, well, run until your asynchronous operation is done, only then letting the test exit.
Another take on this from Mike Zornek.
No Comments Yet