假设我在 Xcode 有一个现有的项目,不管出于什么原因,没有添加单元测试或 UI 测试。我可以在 Xcode 7的后面将测试项目添加到项目中吗?
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.
File > New > Target > Test
File > New > File > Source
Tests are targets.
Select the project in the navigation view then Menu File > New > Target… and Test of the proper SDK.
Menu File
New
Target…
Test
Choose UI Testing Bundle or Unit Test Bundle.
UI Testing Bundle
Unit Test Bundle
Repeat the procedure to add the other test bundle.
Follow this steps,it works's fine
1.Select the project.
2.Targets->Click the + button->Add iOS UITesting Bundle or iOS UnitTesting Bundle.
Xcode add test to target
One more variant Xcode 10.2.1 using Test Navigator
Xcode 10.2.1
Test Navigator
View -> Navigators -> Show Test Navigator
Right click
+
New Unit Test Target...
New UI Test Target...