Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Test After Build" option in XCode 4 not working

So, I am having a bear of a time figuring this one out. I have looked around, and cannot seem to find any information on this.

What I want to do is have my unit tests ALWAYS run EVERY time I build my code in XCode. I have read a number of posts, including this question here. I have followed the instructions to the letter, and the build will not run the tests.

What I have done:

  • My Test suite is a target dependency of my main build
  • My main build has "Test After Build" set to Yes
  • All of the tests under the "test" phase in the Scheme are there, and checked

If I run the tests manually - through cmd+U or the menu - the tests run. I have added a failing test to try and force the build to fail - so I can be sure they are running. The build continues to pass fine, and the tests are never run.

I am positive I have missed a step in here, but for the life of me I cannot find any documentation related to it. Anyone have any other advice or steps I should be doing?

like image 961
aperkins Avatar asked Jul 16 '11 22:07

aperkins


People also ask

In which build phase are unit tests run?

Unit Testing is done during the development (coding phase) of an application by the developers.

How do I add tests to Xcode?

To add a unit test target to an existing Xcode project, choose File > New > Target. Select your app platform (iOS, macOS, watchOS, tvOS) from the top of the New Target Assistant. Select the Unit Testing Bundle target from the list of targets.

How do I run a single test in Xcode?

With a keyboard shortcutHit ^ ⌥ ⌘ U to run the tests for the cursor's context. If you are inside a test method, like in the example below, the context will be that method. If your cursor is in a test class, but outside a method, the context will be that test calls; all its tests will run.

How do I run a test multiple times in Xcode?

Enable test repetition in your test plan, xcodebuild , or by running your test from the test diamond by Control-clicking and selecting Run Repeatedly to bring up the test repetition dialog.


1 Answers

It doesn't matter whether or not "Test After Build" is set to yes or no in your Something.app target. It is only necessary to set "Test After Build" to YES in the unit test target. Also make sure that both "Test" and "Run" are selected for your unit test target in the scheme editor under the "Build" tab options. To see the results click on the Log Navigator View > Navigators > Show Log Navigator (command 7).

like image 81
jaredsinclair Avatar answered Oct 17 '22 03:10

jaredsinclair