, benim NSOperation bitirir sağlamak için -[XCTestCase keyValueObservingExpectationForObject:keyPath:handler:]
yöntemi kullanıyorum olduğunu code from my XCDYouTubeKit project:XCTest istisna keyValueObservingExpectationForObject kullanırken burada, sipariş benim birim testlerinde
- (void) testStartingOnBackgroundThread
{
XCDYouTubeVideoOperation *operation = [[XCDYouTubeVideoOperation alloc] initWithVideoIdentifier:nil languageIdentifier:nil];
[self keyValueObservingExpectationForObject:operation keyPath:@"isFinished" handler:^BOOL(id observedObject, NSDictionary *change)
{
XCTAssertNil([observedObject video]);
XCTAssertNotNil([observedObject error]);
return YES;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
XCTAssertFalse([NSThread isMainThread]);
[operation start];
});
[self waitForExpectationsWithTimeout:5 handler:nil];
}
Bu test her zaman zaman geçer Ben bu hata ile yerel olarak benim Mac üzerinde ama bazen fails on Travis çalıştırmak: yanlış bir şey yapıyor muyum
failed: caught "NSRangeException", "Cannot remove an observer <_XCKVOExpectation 0x1001846c0> for the key path "isFinished" from <XCDYouTubeVideoOperation 0x1001b9510> because it is not registered as an observer."
?
@ Cœur [Genel Konsensus] (https://meta.stackoverflow.com/questions/274906/should-questions-that-violate-api-terms-of-service-be-flagged) bunun stackoverflow kullanıcılarının veya moderatörlerinin diğer web sitelerinin ToS'sini zorlama sorumluluğu. –