2

キウイテストを実施しました。4 回の実行に 1 回、EXC_BAD_ACCESS 例外が発生します。これの原因は何ですか?

expectFutureValue呼び出された最初の非同期テストの途中で停止します。何が問題になる可能性がありますか?これはテストです:

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

4 回の実行に 1 回、EXC_BAD_ACCESS 例外が発生します。これの原因は何ですか?

詳細: スタックトレース 墜落の様子 BIG XCODE イメージ

evaluatenil チェックの方法も変更しました。

- (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];
}

これは結果ログです WHEN FAILURE NOT OCCURS: (テスト自体は失敗しましたが、プログラムはうまく動作します)


テスト ケース '-[NetworkTest TheCallToTheExternalService_Context_ShouldReturnAnIPAddress]' が開始されました。2013-06-04 11:24:24.509 otest[8689:303] 件名は NIL です

/Users/.../KiwiTests/BMNetworkManagerTests.m:81: エラー: -[NetworkTest TheCallToTheExternalService_Context_ShouldReturnAnIPAddress]: '外部サービスへの呼び出し、コンテキストは、IP アドレスを返す必要があります' [FAILED]、「10.1. 48.23、194.50.118.230」、「10.1.48.252、194.50.118.230」を取得


4

0 に答える 0