Note that there are some explanatory texts on larger screens.

plurals
  1. POKiwi - Expected subject to be nil, got KWAsyncVerifier
    primarykey
    data
    text
    <p>I'm using Kiwi to write the tests for my app.</p> <p>I wrote tests to test against my API. I was guided by this example in the documentation for testing asynchronous calls: <a href="https://github.com/allending/Kiwi/wiki/Asynchronous-Testing" rel="nofollow">https://github.com/allending/Kiwi/wiki/Asynchronous-Testing</a> </p> <p>My tests are long, so I made a simplified version of my issue:</p> <pre><code>describe(@"My Class Name", ^{ context(@"populate", ^{ it(@"download the content", ^{ __block NSString *testResponseObject = nil; __block NSError *testError = nil; MyClient *apiClient = [MyClient sharedClient]; NSMutableURLRequest *request = [apiClient requestWithMethod:@"DELETE" path:@"my/path" parameters:nil]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { testResponseObject = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { testError = error; }]; [apiClient enqueueHTTPRequestOperation:operation]; [[expectFutureValue(testResponseObject) shouldEventuallyBeforeTimingOutAfter(100)] equal:@"Expected Content"]; [[expectFutureValue(testError) shouldEventuallyBeforeTimingOutAfter(100)] shouldBeNil]; }); }); }); </code></pre> <p>The thing is that if everything works as expected &amp; the operation succeeds the failure block never gets called &amp; instead of nil for NSError I get KWAsyncVerifier.</p> <p>I'm guessing that's because Kiwi waits for the block where testError is referenced to be executed which never happens &amp; that's why I have KWAsyncVerifier stuck into testError instead of nil.</p> <p>Is there any alternative how to test this out?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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