Configuring a Scheme to Run Unit Tests

A scheme’s Test action identifies the unit-test targets the scheme uses to run unit tests. In the Test action, you specify which unit-test targets, test suites, and test cases you want the scheme to run.

If Xcode autocreates schemes for you after you add a unit-test target to your project, Xcode creates a scheme configured to run the unit tests in that target. You can also modify other schemes or add new schemes to run your unit tests.

Adding a Unit-Test Target to a Scheme

Before you can add a unit-test target to a scheme, ensure your project if properly configured for unit-testing. See Setting Up Unit-Testing in a Project to learn how.

To add a unit-test target to a scheme:

  1. From the Scheme toolbar menu, choose the scheme to which you want to add the unit-test target.

  2. From the same menu, choose Edit Scheme.

  3. Select the Test action.

    ../art/scheme_editor-empty_test_action.jpg
  4. In the Test action Info pane, click the Add button.

  5. Select the unit-test target you want to add to the Test action, and click Add.

    ../art/scheme_target_chooser.jpg

Creating a Scheme that Runs Unit Tests

To create a scheme that runs the unit tests implemented in a unit-test target:

  1. From the Scheme toolbar menu, choose New Scheme.

  2. Specify the following information:

    • Target: Choose the unit-test target you want the scheme to use.

    • Name: Enter a name for the scheme.

    ../art/new_scheme_dialog.jpg
  3. Click OK.