3 つの非同期テストがあります。Xcode 内でテストするとすべて正常に動作しますが、テスト ケースを xcodebuild でビルドすることはできません。XCTestExpectation に関連する 11 のビルド エラーが発生します。
例:
error: unknown type name 'XCTestExpectation' @property XCTestExpectation *expectationNoImage;
最新のコマンド ライン ツール (Xcode 6.1.1) を使用しています。xcodebuild -version はそれを正しく述べています。
次のコマンドでビルドを実行しています
xcodebuild -project myprojasync.xcodeproj -scheme testScheme -configuration Debug -sdk iphonesimulator7.1 clean test | ocunit2junit
非同期テストとそれに対応するテストをコメントアウトすると、すべてが同じコマンドで完全に実行されます。
編集:これはテスト方法の1つです。
@property XCTestExpectation *expectationPass;
-(void)testTaskPass{
//Expectation
self.expectationPass = [self expectationWithDescription:@"Testing Async Works"];
[self.asyncTask getInfo]; //asynchronous call
[self waitForExpectationsWithTimeout:5.0 handler:nil];
}
-(void)returnedFrom:(NSURL *)url with:(UIImage *)image{
if([[url absoluteString] isEqualToString: @"http://correcturl.com"]){
[self.expectationPass fulfill];
}
}