将单元和 UI 测试添加到 Xcode 7 中的现有项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34744508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:25:15  来源:igfitidea点击:

Adding Unit and UI tests to an existing project in Xcode 7

xcode

提问by an earwig

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?

假设我在 Xcode 中有一个现有项目,无论出于何种原因,都没有添加单元测试或 UI 测试。我可以稍后在 Xcode 7 中将测试项目添加到项目中吗?

回答by Chris Droukas

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.

您可以通过导航 为 UI 和单元测试添加新的测试目标File > New > Target > Test。完成后,通过导航添加新的测试用例File > New > File > Source

Test Target

测试目标

回答by vadian

Tests are targets.

测试是目标。

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

在导航视图中选择项目,然后选择Menu File> New>Target…Test合适的 SDK。

Choose UI Testing Bundleor Unit Test Bundle.

选择UI Testing BundleUnit Test Bundle

Repeat the procedure to add the other test bundle.

重复该过程以添加另一个测试包。

回答by yoAlex5

One more variant Xcode 10.2.1using Test Navigator

另一种变体Xcode 10.2.1使用Test Navigator

  1. ? Command+ 6or View -> Navigators -> Show Test Navigator
  2. Right clickor +at the bottom
  3. New Unit Test Target...or New UI Test Target...
  1. ? Command+6View -> Navigators -> Show Test Navigator
  2. Right click+在底部
  3. New Unit Test Target...或者 New UI Test Target...

enter image description here

在此处输入图片说明

回答by Preetha

Follow this steps,it works's fine

按照这个步骤,它工作正常

1.Select the project.

1.选择项目。

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

2.Targets->点击+按钮->添加iOS UITesting Bundle或iOS UnitTesting Bundle。