简体   繁体   English

使用类中的xctest框架运行测试类

[英]run test classes using xctest framework from a class

i am facing a problem. 我面临一个问题。 I want to do a ui test for my application. 我想为我的应用程序做一个ui测试。

i have written six test class where my test cases are included. 我写了六个测试类,其中包括我的测试用例。

I can run my test cases using 我可以使用以下方式运行测试用例

"command U" or the clicking in the run button.

But i don't want to do like this. 但是我不想这样。

I want to run my test classes using code i mean using 我想使用我要使用的代码运行测试类

xctest because after complete my execution, i have to do another task.

can anyone please give an example how i can run my test classes using xctest codding from a class file. 任何人都可以举一个例子,我如何使用来自类文件的xctest codding运行我的测试类。

i dont want to use shell script or jenkins, i want it by using xctest framework. 我不想使用shell脚本或詹金斯,我希望通过使用xctest框架。

Running tests with xcodebuild The xcodebuild command-line tool drives tests just like the Xcode IDE. 使用xcodebuild运行测试xcodebuild命令行工具像Xcode IDE一样驱动测试。 Run xcodebuild with the action test and specify different destinations with the -destination argument. 使用操作测试运行xcodebuild,并使用-destination参数指定不同的目标。 For example, to test MyApp on the local OS X “My Mac 64 Bit,” specify that destination and architecture with this command: 例如,要在本地OS X“我的Mac 64位”上测试MyApp,请使用以下命令指定目标位置和体系结构:

> xcodebuild test -project MyAppProject.xcodeproj -scheme MyApp -destination 'platform=OS X,arch=x86_64'

If you have development-enabled devices plugged in, you can call them out by name or id. 如果插入了支持开发的设备,则可以按名称或ID对其进行调出。 For example, if you have an iPod touch named “Development iPod touch” connected that you want to test your code on, you use the following command: 例如,如果您要测试其代码的iPod touch名为“ Development iPod touch”,则可以使用以下命令:

> xcodebuild test -project MyAppProject.xcodeproj -scheme MyApp -destination 'platform=iOS,name=Development iPod touch'

Tests can run in Simulator, too. 测试也可以在模拟器中运行。 Use the simulator to target different form factors, operating systems, and OS versions easily. 使用模拟器可以轻松地针对不同的外形尺寸,操作系统和操作系统版本。 Simulator destinations can be specified by name or id. 可以通过名称或ID指定模拟器目标。 For example: 例如:

> xcodebuild test -project MyAppProject.xcodeproj -scheme MyApp -destination 'platform=Simulator,name=iPhone,OS=8.1'

Source 资源

  1. Edit your Xcode scheme. 编辑您的Xcode方案。
  2. Click the disclosure triangle next to "Test" to reveal more options. 单击“测试”旁边的显示三角形以显示更多选项。
  3. Select "Post-actions" 选择“后动作”
  4. Click '+' to add any actions to run after tests are complete. 单击“ +”添加测试完成后要运行的所有操作。

在此处输入图片说明

As you can see, your choices are to run a script, or send a simple email. 如您所见,您的选择是运行脚本或发送简单的电子邮件。 For more information on configuring actions, see https://michele.io/the-project-file-part-2/ 有关配置操作的更多信息,请参见https://michele.io/the-project-file-part-2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM