Xcode 5:单元测试未运行

inv*_*ent 11 testing xcode unit-testing objective-c ios

我创建了一些测试用例,它们都通过了...那是因为它们没有被运行.

从Xcode,我得到:

Test Suite 'All tests' started at...
Test Suite 'All tests' finished at...
Executed 0 tests, with 0 failures (0 unexpected) in 0.00 seconds

项目(和单元测试类)构建成功.

我的所有测试类都选择了MyApp_appTests作为目标成员.生产类选择了MyApp_app和MyApp_appTests目标.

我验证了MyApp_appTests目标构建设置(捆绑加载器和测试主机).

Bundle Loader (Debug): $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp
Test Host (Debug): $(BUNDLE_LOADER)
Run Code Online (Sandbox Code Playgroud)

我已经导入了SenTestingKit.framework(通过Targets Build Phases"Link Binary with Libraries").

我的所有测试都以 -(void)testThat...

我还检查了一些stackoverflow.com问题:

stackoverflow.com/questions/8632254/xcode-4-2-cant-run-unit-test stackoverflow.com/questions/3608484/ocunit-tests-not-running-not-being-found stackoverflow.com/questions/16672616/的OCUnit试验的情况下,不运行的

这篇文章:

twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/

我不知道在哪里寻找...非常感谢任何帮助!

kra*_*g22 23

对于我来说,在测试目标的构建设置中将"包装扩展"从"octest"更改为"xctest"

在此输入图像描述


zap*_*aph 5

Xcode 5现在使用的是XCTestCase,而不是SenTest.Apple现在更直接地支持单元测试,包括他们自己的名为XCTestCase的SenTest版本.此外,UI得到了很大改进,允许运行单个测试,测试导航器,不再创建.h测试文件.请注意,测试宏不是使用XC前缀重命名.

参见WWDC-13视频409:"在Xcode 5中测试".

如果使用Xcode 5模板创建测试环境,项目将包括测试目标和工作(和失败)测试.

  • 实际上在Xcode 5中,OCUnit与XCTest共存 (9认同)