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

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

问题描述

是否可以从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?

您可以使用从命令行运行测试xcodebuild ,开箱即用.这样做时,您将运行所选测试目标中包含的所有测试用例.

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.

您也可以使用Fastlane的扫描来执行此操作,尽管我认为您仅限于运行全部选择的构建方案的测试(如上所述),因此与xcodebuild没什么不同.

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.

您可以使用来自Facebook的 xctool 运行特定的测试,但是它不使用xcodebuild,并且仅限在模拟器上运行,而不是在实际的iOS测试设备上运行.

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.

我找到了运行在单独的XCTRunner中拥有* xctest文件,这一事实使情况变得复杂包.

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.

推荐答案

对于Xcode 8,现在可以将-only-testing参数与xcodebuild一起使用:

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

查看此视频: https://developer.apple.com/videos/play /wwdc2016/409/

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

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