从命令行为 iOS 应用程序运行单独的 XCTest(UI、Unit)测试用例 [英] Running individual XCTest (UI, Unit) test cases for iOS apps from the command line

查看:47
本文介绍了从命令行为 iOS 应用程序运行单独的 XCTest(UI、Unit)测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从 iOS 应用测试目标运行单个测试用例或单个测试套件,而不是从命令行界面运行所有测试用例?

您可以使用

Is it possible to run individual test cases, or individual test suites, from an iOS app test target, instead of all the test cases, from a command line interface?

You can run tests from command line with xcodebuild, out of the box. When you do so, you run all of the test cases contained in the test target you've selected.

You can also do so with scan from Fastlane, though I believe you're restricted to running all of the tests of the build scheme you select (as above), so it's not different from xcodebuild.

You can run specific tests with xctool from Facebook, but it doesn't use xcodebuild, and is restricted to running on simulators only, not actual iOS test devices.

I found a reference to running the xctest command line utility directly, but it seems to be an undocumented feature and targets DerivedData. This is complicated by the fact that UI Tests, have their *xctest files in a separate XCTRunner bundle.

解决方案

It is now possible with Xcode 8 using the -only-testing parameter with xcodebuild:

xcodebuild test -workspace <path>
                -scheme <name>
                -destination <specifier>
                -only-testing:TestBundle/TestSuite/TestCase

这篇关于从命令行为 iOS 应用程序运行单独的 XCTest(UI、Unit)测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆