Reputation: 2465
I created a few test cases and they all passed... That's because they are not being run.
From Xcode, I get:
Test Suite 'All tests' started at... Test Suite 'All tests' finished at... Executed 0 tests, with 0 failures (0 unexpected) in 0.00 seconds
The project (and unit test classes) build successfully.
All my test classes have MyApp_appTests as Target Membership selected. Production classes have MyApp_app & MyApp_appTests targets selected.
I verified the MyApp_appTests Target Build Settings (Bundle Loader & Test Host).
Bundle Loader (Debug): $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp
Test Host (Debug): $(BUNDLE_LOADER)
I have imported SenTestingKit.framework (through Targets Build Phases "Link Binary With Libraries").
All my tests start with -(void)testThat...
I have also checked a few stackoverflow.com questions:
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-test-cases-not-running
and this post:
twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
I don't know where to look for... Any help is greatly appreciated!
Upvotes: 11
Views: 11403
Reputation: 5772
I had this problem with Xcode 7.3, what worked for me was running the application on the device once and then running the tests.
Upvotes: 0
Reputation: 931
If you are creating a new test target in Xcode 5+ and planning to use SenTestKit for unit tests, changing the 'Wrapper Extension' build setting of your test target to 'octest' from the default 'xctest' will help execute the test cases.
Upvotes: 0
Reputation: 3524
For me worked changing "Wrapper extension" from "octest" to "xctest" in Build Settings for tests target
Upvotes: 23
Reputation: 112875
Xcode 5 now used XCTestCase, not SenTest. Apple is now supporting Unit Testing more directly including their own version of SenTest named XCTestCase. Additionally the UI is much improved, allowing individual tests to be run, a Test Navigator and no longer creating .h test files. Note that the test macros are not renames with an XC prefix.
See the WWDC-13 video 409: "Testing in Xcode 5".
If you use the Xcode 5 template to create the testing environment the project will include a test target and a working (and failing) test.
Upvotes: 5