Note that there are some explanatory texts on larger screens.

plurals
  1. POKiwi asynchronous test raises EXC_BAD_ACCESS
    text
    copied!<p>I have a Kiwi test performed. Once in 4 runs it raises EXC_BAD_ACCESS exception. What could be the cause of this?</p> <p>It stops in the middle of first asynchronous test with <code>expectFutureValue</code> invoked. What could go wrong? This is the test:</p> <pre><code>SPEC_BEGIN(NetworkTest) describe(@"The call to the external service", ^{ context(@"context", ^{ __block id origin = nil; __block int x = 0; __block AFJSONRequestOperation *operation; beforeEach(^{ /* [OHHTTPStubs addRequestHandler:^OHHTTPStubsResponse*(NSURLRequest *request, BOOL onlyCheck){ return [OHHTTPStubsResponse responseWithFile:@"test.json" contentType:@"text/json" responseTime:1.0]; }]; */ origin = nil; NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://httpbin.org/ip"]]; operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { origin = [JSON valueForKeyPath:@"origin"]; x = 1; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { // no action origin = @"no"; }]; [operation start]; }); afterEach(^{ origin = @""; operation = nil; }); it(@"should be not nil", ^{ [[expectFutureValue(origin) shouldEventuallyBeforeTimingOutAfter(3.0)] shouldNotBeNil]; }); it(@"should set x to 1", ^{ [[expectFutureValue(theValue(x)) shouldEventuallyBeforeTimingOutAfter(3.0)] equal:theValue(1)]; }); it(@"should return an IP address", ^{ [[expectFutureValue(origin) shouldEventuallyBeforeTimingOutAfter(3.0)] equal:@"10.1.48.223, 194.50.118.230" ]; }); }); }); SPEC_END </code></pre> <p>Once in 4 runs it raises EXC_BAD_ACCESS exception. What could be the cause of this?</p> <p>More details: <a href="https://gist.github.com/prometedor/5697518" rel="nofollow noreferrer" title="STACK TRACE">STACK TRACE</a> <img src="https://i.stack.imgur.com/0SFpp.png" alt="State of crash"> <a href="https://i.imgur.com/iTmPXrX.png" rel="nofollow noreferrer">BIG XCODE IMAGE</a></p> <p>I have also modified <code>evaluate</code> method for nil check:</p> <pre><code>- (BOOL)evaluate { if (self.subject == nil) { NSLog(@"The subject is NIL"); } /** handle this as a special case; KWValue supports NSNumber equality but not vice-versa **/ if ([self.subject isKindOfClass:[NSNumber class]] &amp;&amp; [self.otherSubject isKindOfClass:[KWValue class]]) { return [self.otherSubject isEqual:self.subject]; } return [self.subject isEqual:self.otherSubject]; } </code></pre> <p>and this is result log WHEN FAILURE NOT OCCURS: (the test itself is failed, but program works well)</p> <hr> <p>Test Case '-[NetworkTest TheCallToTheExternalService_Context_ShouldReturnAnIPAddress]' started. 2013-06-04 11:24:24.509 otest[8689:303] The subject is NIL</p> <p>/Users/.../KiwiTests/BMNetworkManagerTests.m:81: error: -[NetworkTest TheCallToTheExternalService_Context_ShouldReturnAnIPAddress] : 'The call to the external service, context, should return an IP address' [FAILED], expected subject to equal "10.1.48.23, 194.50.118.230", got "10.1.48.252, 194.50.118.230"</p> <hr>
 

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