Note that there are some explanatory texts on larger screens.

plurals
  1. POCan OCUnit rely on code in background threads? (in order to test asynchronous requests)
    primarykey
    data
    text
    <p>I've been trying to automate tests on asynchronous requests but I haven't been able to run anything in a different thread while the test function was waiting. Here is the test function:</p> <pre><code>- (void) testBoxManagerConnexionStatus { ControlSender* cs = [ControlSender get]; requestShouldSucceed = YES; [cs startCheckingReachabilityWithDelegate:self]; [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:TIMEOUT_INTERVAL+1.0]]; STAssertTrue(downloadComplete, @"Download should be over by now"); } </code></pre> <p>My test class implements the callback methods this way:</p> <pre><code>- (void)controlSender:(ControlSender *)controlSender sentSuccessfullyCode:(FreeboxControl)code { if (requestShouldFail) { STAssertTrue(NO, @"Request should have failed"); } downloadComplete = YES; } - (void)controlSender:(ControlSender *)controlSender couldntSendCode:(FreeboxControl)code details:(NSHTTPURLResponse*)details { if (requestShouldSucceed) { STAssertTrue(NO, @"Request should have succeded"); } downloadComplete = YES; } </code></pre> <p>But whenever my usual code try to run something in a different thread nothing happens. For example the NSURLConnection never call its delegate methods when allocated:</p> <pre><code>m_connexion = [[NSURLConnection alloc] initWithRequest:m_networkRequest delegate:self]; </code></pre> <p>Neither the <code>-connectionDidFinishLoading:</code> nor the <code>-connection:didFailWithError:</code></p> <p>Same thing for calls like this one:</p> <pre><code>[self performSelectorInBackground:@selector(BG_startCheckingReachabilityWithDelegate:) withObject:delegate]; </code></pre> <p>Nothings gets called in background when running the test. The same code works fine outside of the test though. Is there any way to test asynchronous url request with OCUnit?</p> <p>Thanks for the help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload