Adding Test Targets

Expand the scope of your testing by adding test targets to a project.

bullet
To add test targets
  1. Click the Add button (+) in the test navigator filter bar.

    ../Art/tnh-addtesttrgt-1_2x.png
  2. From the pop-up menu, choose New Test Target.

    ../Art/tnh-addtesttrgt-2_2x.png
  3. Specify the test target options.

    • Product Name: A name for the new test target.

    • Project: The project that contains the new test target.

    • Language: The implementation language, Objective-C or Swift.

    • Target: The target associated with the new test target.

      Xcode configures the new test target to run tests using the associated target, which can be any target contained by the project except a test target.

      ../Art/tnh-addtesttrgt-3_2x.png
  4. Click Finish.

    Xcode adds a new target and class to the test navigator, including stub implementations for the setUp, tearDown, testExample, and testPerformanceExample methods.

    ../Art/tnh-addtesttrgt-4_2x.png
  5. Complete the stub implementations, and add other code as necessary.