If you started an Xcode project a long time ago or just didn’t tick the “Include Unit Tests” box when creating your project, it may be a bit confusing how to get them in. Not to fear, I will show you how.
First, head over your project summary. Down the bottom click the “Add Target” button.
Select the Touch Unit Testing Bundle from the Other iOS category.
Pretty easy right? Well this doesn’t quite get us to where we would have been by adding the Unit Tests in from the beginning, and this is where most people get stuck…
The standard Unit Tests allow you to use the Command+U shortcut to run the tests for the current target. This wont work yet because our tests are not associated with any target.
Through the menu, select “Product > Scheme > Edit Scheme…”. Make sure your target is selected at the top in the drop down box and select the Test option on the left. Now click the add button and choose your unit test.
That’s about it. Now you can run tests with the Command+U shortcut.
If you also want to remove the Unit Test from the Schemes list (as per a project begun with Unit Tests), in the screen above choose Manage Schemes just below the add button, then select the Unit Test and delete it.