Search code examples
unit-testingxcode

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.


Solution

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