I have a Kiwi test performed. Once in 4 runs it raises EXC_BAD_ACCESS exception. What could be the cause of this?
It stops in the middle of first asynchronous test with expectFutureValue
invoked. What could go wrong?
This is the test:
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
Once in 4 runs it raises EXC_BAD_ACCESS exception. What could be the cause of this?
More details:
STACK TRACE
BIG XCODE IMAGE
I have also modified evaluate
method for nil check:
- (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]] && [self.otherSubject isKindOfClass:[KWValue class]]) {
return [self.otherSubject isEqual:self.subject];
}
return [self.subject isEqual:self.otherSubject];
}
and this is result log WHEN FAILURE NOT OCCURS: (the test itself is failed, but program works well)
Test Case '-[NetworkTest TheCallToTheExternalService_Context_ShouldReturnAnIPAddress]' started. 2013-06-04 11:24:24.509 otest[8689:303] The subject is NIL
/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"