【发布时间】:2015-02-25 15:27:38
【问题描述】:
我有三个异步测试。在 Xcode 中测试时一切运行良好,但无法使用 xcodebuild 构建测试用例。我得到 11 个与 XCTestExpectation 相关的构建错误。
例子:
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
如果我注释掉异步测试及其对应项,则所有内容都可以使用相同的命令完美运行。
编辑:这是其中一种测试方法。
@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];
}
}
【问题讨论】:
-
你好,请把测试方法放在这里,这样会更容易看到发生了什么...tkx
标签: ios objective-c xcode xctestexpectation