【发布时间】:2014-03-14 20:18:43
【问题描述】:
我想为我的库创建逻辑测试并在 iOS 设备上运行它们。我知道我们只能在模拟器上运行它们。但我已经看到我可以在 iOS 设备上运行默认测试。这是设置。
- 使用 xcode 5 创建新的 iOS 7.0 应用(单视图应用,没什么花哨的)。
- 这将创建默认测试,该测试失败并显示消息 failed - No implementation for "-[MyAppTests testExample] 当您尝试运行它时。
- 我能够使用具有相同输出的 xcode 在模拟器和设备上运行此测试。
这是否意味着我也可以在设备上运行 XCTests?
此外,当我尝试使用命令行运行相同的测试时,它给我一个错误,说该方案不可测试。 Xcode 为何能够运行它?这是我在设备上执行的命令行。
xcodebuild test -scheme MyApp -configuration Debug -destination name=TestIPhone
我看到以下消息
2014-03-14 16:04:12.423 xcodebuild[620:1207] [MT] DVTAssertions: Warning in /SourceCache/IDEFoundation/IDEFoundation-3582/Framework/Classes/Model/Execution/RunContext/IDEScheme.m:1290
Details: Scheme <IDEScheme:0x7ff6abc8d2b0:'MyAppTests'> was asked to test, but it is not testable and shouldn't have allowed this action.
Object: <IDEScheme: 0x7ff6abc8d2b0>
Method: -testOperationWithExecutionContext:buildIfNeeded:onlyBuild:destination:overridingProperties:overridingTestingSpecifiers:buildLog:overridingBuildConfiguration:restorePersistedBuildResults:invocationRecord:name:title:error:actionCallbackBlock:
Thread: <NSThread: 0x7ff6abc0e5d0>{name = (null), num = 1}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
xcodebuild: error: Failed to build project MyAppTests with scheme MyAppTests.
Reason: Scheme "MyAppTests" is not testable.
任何见解都会有所帮助。我很困惑。
【问题讨论】:
标签: xctest