11

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!

Community
  • 1
  • 1
invalidArgument
  • 2,289
  • 4
  • 24
  • 35
  • YOudo not need to import `SenTestingKit.framework` in Xcode 5. Check the WWDC-13 video on Xcode 5 unit tests. – zaph Sep 22 '13 at 20:33
  • If I don't, I get Build errors (_OBJC_METACLASS_$_SenTestCase" shows as undefined symbol for armv7 architecture). Does that reveal a bad configuration in my project? – invalidArgument Sep 22 '13 at 20:50
  • 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. – zaph Sep 22 '13 at 21:30
  • You pointed me to the right direction: The included class uses XCTestCase instead of SenTest. Changing frameworks made it work (and fail!) for me. Do you know why? Is SenTest Framework deprecated? Note that if you wrap your explanation/comments in an answer, it will get accepted, since it helped me resolve my issue. Thanks for your help! – invalidArgument Sep 23 '13 at 00:10

4 Answers4

23

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

enter image description here

kraag22
  • 3,340
  • 3
  • 29
  • 37
  • 1
    This worked for me. I needed to do this after selecting Edit->Refactor->Convert to XCTest... – J.C. Feb 18 '14 at 20:26
  • In my case, I had not refactored existing tests, I noticed all SenTests were being executed and displayed in the test navigator (Xcode 5.1) but while the new XCTestCase was listed in the navigator it was never invoked - breakpoints never hit, etc. Switching wrapper extension to `xctest` triggered running of both types of tests in the same project. – Scott Heaberlin May 15 '14 at 02:00
5

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.

Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75
zaph
  • 111,848
  • 21
  • 189
  • 228
0

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.

ram
  • 921
  • 7
  • 8
0

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.

jarora
  • 5,384
  • 2
  • 34
  • 46