James Parsons
James Parsons

Reputation: 6057

Adding Unit and UI tests to an existing project in Xcode

Lets say I have an existing project in Xcode, and for whatever reason, did not add Unit Tests or UI Tests. Can I add the test projects to the project later in Xcode 7?

Upvotes: 99

Views: 34664

Answers (5)

Zulqarnain Mustafa
Zulqarnain Mustafa

Reputation: 1653

Here is how you can do that in Xcode 15.0

Click +

A template view will appear search test: Template View

Confirm view

Added

Here is test case file

Upvotes: 1

yoAlex5
yoAlex5

Reputation: 34255

Xcode add a test to a target

One more variant Xcode 10.2.1 using Test Navigator

  1. ⌘ Command + 6 or View -> Navigators -> Show Test Navigator
  2. Right click or + at the bottom
  3. New Unit Test Target... or New UI Test Target...

Upvotes: 15

Preetha
Preetha

Reputation: 749

Follow this steps,it works's fine

1.Select the project.

2.Targets->Click the + button->Add iOS UITesting Bundle or iOS UnitTesting Bundle.

Upvotes: 6

vadian
vadian

Reputation: 285072

Tests are targets.

Select the project in the navigation view then Menu File > New > Target… and Test of the proper SDK.

Choose UI Testing Bundle or Unit Test Bundle.

Repeat the procedure to add the other test bundle.

Upvotes: 20

Chris Droukas
Chris Droukas

Reputation: 3196

Yes!

You can add new test targets for UI and unit tests by navigating File > New > Target > Test. When that's done, add new test cases by navigating File > New > File > Source.

Test Target

Upvotes: 146

Related Questions