I have written an OCUnit unit test case which relies on an external web-service to complete. I know this is controversial in itself but I definitely want to have the web-service included in the tests (it's running on an internal server anyway).
Apparently, the NSURLConnection fails to start when run as part of the SenTestCase. The connection is not started at all by the line:
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self startImmediately:YES];
None of the delegate methods are called. Virtually identical code runs normally outside of OCUnit.
What is it about the OCUnit runtime environment that prevents this from running?
It's not that the test completes before the request returns: I have NSCondition locks to handle the asynchronous nature of the request. I've also tried removing these and just spinning on the run loop. The test case continues to execute but the NSURLConnection never starts.
I'd rather not migrate my testing to another Unit Testing Framework if possible.