이상한 알 수없는 이유로이 테스트는 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를 얻습니다.
광고주 ID를받지 못했습니다. <--- 내가 너라면이 문제를 조사 할 것입니다. 그것 때문에 빈 문자열이 나올 가능성이 큽니다. – borrrden
나는 그것에 대해서도 생각했지만 stacktrace는 조금 더 이상합니다. 또한 Xcode 내 단위 테스트 환경에서 실행되므로 advertiserID를 얻습니다. 단지 xctool과 멋진 통합이 아닌가? – jonalmeida
또한이 질문은 유사하며 광고주가 답변 한 사람은 테스트에서 광고주 ID가 획득되었음을 보여줍니다. http://stackoverflow.com/questions/18022360/what-is-this-vendorid-error-message-associated-with- can not-connect-to-itunes-f – jonalmeida