Question

How to run single test case in Xcode?

I know it is best practice to run all unit test cases after any change to make sure not breaking anything. However, some times, e.g. debugging, I really want to run only one single test case. It seems Xcode doesn't provide any such feature in UI, while other testing framework such as JUnit has such features.

Is there any workaround to have only one testcase run in Xcode?

P.S. most of my test cases are logic tests. So, they are not run in iPhone device.

 45  21670  45
1 Jan 1970

Solution

 50

Xcode 4 now have this feature. Simply create a "run scheme"  that has the test cases that you want to run.

  1. Open menu "Product|Edit Scheme..."
  2. Click on "Edit..."
  3. In the left pane, expand the "Test" section.
  4. In the right pane, expand the test bundle and uncheck the test cases you don't need to run.
2011-08-17

Solution

 38

+++U

You can also use the keyboard short cut of Control-Option-Command-U

Expert taken from Apple Documentation

Product > Perform Action > Test . This dynamic menu item senses the current test method in which the editing insertion point is positioned when you’re editing a test method and allows you to run that test with a keyboard shortcut. The command’s name adapts to show the test it will run, for instance, Product > Perform Action > Test testAddition. The keyboard shortcut is Control-Option-Command-U.

2014-09-02