Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 5: Unit Tests not running

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!

like image 863
invalidArgument Avatar asked Sep 22 '13 20:09

invalidArgument


People also ask

How do I run unit tests in Xcode?

⌘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.

How do I enable test coverage in Xcode?

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.

Does Xcode run tests in parallel?

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).

How do I add unit tests to Xcode project?

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.


2 Answers

For me worked changing "Wrapper extension" from "octest" to "xctest" in Build Settings for tests target

enter image description here

like image 144
kraag22 Avatar answered Oct 19 '22 23:10

kraag22


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.

like image 39
zaph Avatar answered Oct 20 '22 00:10

zaph