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!
⌘U will build and run all your test cases. It is the most commonly used shortcut when creating unit test cases. It is equivalent to ⌘R (build & run) while doing app development. You can use this shortcut to build your test target and run all the test cases in your test target.
Enable code coverage date gathering. To do this, go to Product › Scheme › Edit Scheme... , and select Test from the left hand side menu. Under the Info section, check the Gather coverage data box.
Xcode has the power to randomise unit tests or even run them in parallel, but sometimes in using those features we can make the tests less stable (or show you that they are unstable but just did not notice).
Adding a unit test in Xcode If you already have a project, you can add a Unit Testing Bundle to it as well. Go to File > New > Target. Select iOS Unit Testing Bundle and then click Next.
For me worked changing "Wrapper extension" from "octest" to "xctest" in Build Settings for tests target
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With