Adding Unit Tests to an already existing project?

Answer updated for Xcode 10.2.

Glad you asked this question — it’s never too late to add tests to a project!

  1. Open your targets panel by selecting your project in the navigator,
  2. Click the + button that’s at the bottom of the target list,
  3. Select iOS Unit Testing Bundle under Test section in iOS tab,
  4. Provide the required information and click Done.

It’s that simple. Xcode will generate a target, some boilerplate files such as Info.plist and an initial test case file for you. Happy testing!

Leave a Comment