2014-06-19 2 views
3

이상한 알 수없는 이유로이 테스트는 xctool (0.1.16)에서 실행될 때 실패하지만 XCode를 통해 실행하면 통과합니다. 나는 정확한 동일한 코드를 사용하지만 [[NSUUID UUID] UUIDString]으로 sample_uuid을 대체하기 때문에NSRegularExpression에서 xctool이 충돌하는 이유는 무엇입니까?

- (void)testGetAppleIdfa 
{ 
    NSString *sample_uuid = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; 

    // For regex pattern matching to verify if it's of UUID 
    NSString *pattern = @"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"; 
    NSRange searchRange = NSMakeRange(0, [sample_uuid length]); 
    NSError *error = NULL; 
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error]; 
    NSArray *matches = [regex matchesInString:sample_uuid options:0 range:searchRange]; 

    NSLog(@"UUID generated: %@", sample_uuid); 

    XCTAssertEqual([matches count], 1, @"UUID generated doesn't match the UUID RFC"); 
} 

이 이상한 이유입니다. 이 xctool 콘솔에서 옷을 사는 것입니다

:

2014-06-19 05:50:25.677 xctest[11190:303] LaunchServices: failed to get advertiserID 
Unknown File:0: *** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument 
(
    0 CoreFoundation      0x00b331e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x007a68e5 objc_exception_throw + 44 
    2 CoreFoundation      0x00b32fbb +[NSException raise:format:] + 139 
    3 Foundation       0x00079086 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 215 
    4 Foundation       0x00042735 -[NSRegularExpression(NSMatching) matchesInString:options:range:] + 143 
    5 SnowplowTests      0x02f09462 -[TestUtils testGetAppleIdfa] + 338 
    6 CoreFoundation      0x00b2791d __invoking___ + 29 
    7 CoreFoundation      0x00b2782a -[NSInvocation invoke] + 362 
    8 XCTest        0x20103c6c -[XCTestCase invokeTest] + 221 
    9 XCTest        0x20103d7b -[XCTestCase performTest:] + 111 
    10 otest-shim-ios.dylib    0x00008cc7 XCPerformTestWithSuppressedExpectedAssertionFailures + 172 
    11 otest-shim-ios.dylib    0x00008c15 XCTestCase_performTest + 31 
    12 XCTest        0x20104c48 -[XCTest run] + 82 
    13 XCTest        0x201033e8 -[XCTestSuite performTest:] + 139 
    14 XCTest        0x20104c48 -[XCTest run] + 82 
    15 XCTest        0x201033e8 -[XCTestSuite performTest:] + 139 
    16 XCTest        0x20104c48 -[XCTest run] + 82 
    17 XCTest        0x201033e8 -[XCTestSuite performTest:] + 139 
    18 XCTest        0x20104c48 -[XCTest run] + 82 
    19 XCTest        0x201066ba +[XCTestProbe runTests:] + 183 
    20 libobjc.A.dylib      0x007b8743 +[NSObject performSelector:withObject:] + 70 
    21 xctest        0x0000233e xctest + 4926 
    22 xctest        0x00002590 xctest + 5520 
    23 xctest        0x00002671 xctest + 5745 
    24 xctest        0x00002007 xctest + 4103 
    25 libdyld.dylib      0x01687701 start + 1 

) : 나는 NSArray *matches = [regex matchesInString:sample_uuid options:0 range:searchRange];에서 테스트 충돌이 enumerateMatchesInString:options:range:usingBlock:를 호출 할 때 시행 착오를 통해 알아 냈에서

. 다시 말하지만, 정확히 동일한 형식을 제공하는 다른 UUID 생성기를 전달합니다.

사이드 노트 : 이것은 정규 표현식이 그대로있는 이유는 유형 4 UUID와 일치하지 않아야합니다.

EDIT : xctool -workspace MyApp.xcworkspace -scheme MyApp -sdk iphonesimulator7.1 build test을 사용하는 터미널에서 xctools를 실행할 때 위의 오류가 발생합니다. 그러나 XCode를 통해 테스트를 실행하면 NSLog에서 UUID를 얻습니다.

+0

광고주 ID를받지 못했습니다. <--- 내가 너라면이 문제를 조사 할 것입니다. 그것 때문에 빈 문자열이 나올 가능성이 큽니다. – borrrden

+0

나는 그것에 대해서도 생각했지만 stacktrace는 조금 더 이상합니다. 또한 Xcode 내 단위 테스트 환경에서 실행되므로 advertiserID를 얻습니다. 단지 xctool과 멋진 통합이 아닌가? – jonalmeida

+0

또한이 질문은 유사하며 광고주가 답변 한 사람은 테스트에서 광고주 ID가 획득되었음을 보여줍니다. http://stackoverflow.com/questions/18022360/what-is-this-vendorid-error-message-associated-with- can not-connect-to-itunes-f – jonalmeida

답변

0

같은 것을 추가해야합니다 :

나는 당신이 언급 한 문제를 재현 할 수 있었다. 문제는 입니다. 이제 Xcode에서 모든 테스트를 응용 프로그램 테스트로 실행하고 xctool은 여전히 ​​ 으로 논리 테스트와 응용 프로그램 테스트를 구분합니다.

테스트 번들에 응용 프로그램이 연결되었을 때 테스트를 통과 할 수 있었으며 응용 프로그램 테스트로 간주되었습니다.

자세한 내용은 여기에서 확인할 수 있습니다. What is this vendorID error message associated with "Cannot Connect to iTunes" for in-app purchase?.

0

xctoolXcode과 동일한 시뮬레이터를 시작하는지 확인해야합니다. 시뮬레이터를 시작할 때 -sdk 명령을 구축하는 경우에만 사용되지만 무시하기 때문에 당신이 당신의 명령

xctool -workspace MyApp.xcworkspace -scheme MyApp -sdk iphonesimulator7.1 build test 

에있는 시뮬레이터를 지정하지

참고.

당신은 Github에서에 ExtremeMan에서

-destination 'name=iPhone Retina (4-inch 64-bit),OS=7.1' 
+0

나는 쓸데없는 목적지를 추가하려고했다. XCode가이를 확인하기 위해 사용하는 정확한 구성을 어떻게 알 수 있습니까? – jonalmeida

+0

@jonalmeida 당신은 Xcode에서 어떤 시뮬레이터를 실행하는지 항상 알고 있습니다. 그렇습니까? – Sulthan

+0

예, 있습니다. 나는 XCode가 콘솔을 통해 실행중인 것에서 (대상 옵션 외에) 실행되는 다른 플래그가 추가되었는지 확인하는 방법을 의미했습니다. – jonalmeida

관련 문제