简体   繁体   中英

run test classes using xctest framework from a class

i am facing a problem. I want to do a ui test for my application.

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.

i dont want to use shell script or jenkins, i want it by using xctest framework.

Running tests with xcodebuild The xcodebuild command-line tool drives tests just like the Xcode IDE. Run xcodebuild with the action test and specify different destinations with the -destination argument. For example, to test MyApp on the local OS X “My Mac 64 Bit,” specify that destination and architecture with this command:

> 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. 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:

> 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. For example:

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

Source

  1. Edit your Xcode scheme.
  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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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