Совместимость между GHUnit и AFNetWorking

Привет, я пытаюсь создать модульный тест, используя GHUnit, но у меня есть исключение, я думаю, что это проблема совместимости между AFNetWorking и GHUnit
исключение 'GHTestFailureException', причина: 'не удалось' * Первый стек бросить вызов: (0x1de4012 0x163fe7e 0x1e6cfb1 0x2a4c1 0x2f20 0x137a4 0x191553f 0x1927014 0x19177d5 0x1d8aaf5 0x1d89f44 0x1d89e1b 0x21777e3 0x2177668 0x7b065c 0x1f3c 0x1e95) LibC++abi.dylib: оконечный называется бросать исключение

  NSURL *url = [NSURL @"https://www.myWebsite.com"];
        NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];

        AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:theRequest];


        [operation setAuthenticationChallengeBlock:^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) {
            NSURLCredential *newCredential = [NSURLCredential credentialWithUser:@"login" password:@"password" persistence:NSURLCredentialPersistenceForSession];
            [challenge.sender useCredential:newCredential forAuthenticationChallenge:challenge];
        }];

            NSLog(@"Response from %@",response);

        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

            GHFail(@"failed"); }];


        [operation start];
        [operation waitUntilFinished];

1 ответ

Решение

Возможно, вы захотите посмотреть на асинхронное тестирование GHUnit.

Примеры:

https://gist.github.com/levigroker/1643797

http://vladimir.zardina.org/2010/11/testing-asynchronous-code-with-ghunit/ http://samwize.com/2012/11/25/create-async-test-with-ghunit/ http://samwize.com/2012/10/03/sentestingkit-does-not-support-wait-for-blocks/

Также есть огромный поток об этом на AFNetworkingпроблемы

https://github.com/AFNetworking/AFNetworking/issues/466

Другие вопросы по тегам