简体   繁体   English

运行特定的XCUITests集

[英]Run specific set of XCUITests

The problem is that I want to be able to run specific amount or group of XCUITests, like in Calabash for example. 问题是我希望能够运行特定数量或组的XCUITest,例如在Calabash中。 In Calabash you can run a set of tests marked with specific tag. 在Calabash中,您可以运行一组标有特定标签的测试。 So, I was wondering is there anything that I can do to achieve this? 因此,我想知道有什么办法可以实现? I know that I can split group of tests by bundle or even scheme, but thats not what I am looking for. 我知道我可以按捆绑或什至方案划分测试组,但这并不是我想要的。

So, far I saw that you can run only specific test, but not a group of tests. 因此,到目前为止,我看到您只能运行特定的测试,而不能运行一组测试。

EDIT: 编辑:

Basically I want to be able run command something like: 基本上,我希望能够运行类似以下命令:

xcodebuild test -workspace -scheme -destination -only-testing:UITestBundle -tag xcodebuild test -workspace -scheme -destination -only-testing:UITestBundle -tag

In that way I would be able to test only specific functionality related to small area of my project, so it would not be needed to run all bundle which could potentially take a lot of time. 这样,我将只能测试与项目的小区域相关的特定功能,因此不需要运行所有可能花费大量时间的捆绑软件。 And I would be able to set up this in CI. 而且我可以在CI中设置它。 And it would not be necessary to change my code every time when I need to run different set of tests. 当我需要运行不同的测试集时,不必每次都更改代码。

You can govern the execution by Launch arguments and skip the tests based on the corresponding values. 您可以通过启动参数控制执行,并根据相应的值跳过测试。 Create a Launch Arg like IsSkippingTests and set a value based on your requirement, then at the beginning of each test you can add the the code like: 创建一个类似于IsSkippingTests的启动IsSkippingTests并根据您的要求设置一个值,然后在每个测试的开始处可以添加如下代码:

guard LA.valueOfLA("-IsSkippingTests") == "requiredFunctionality" else { return }

And define a struct LA which will contain valueOfLA static method: 并定义一个结构LA ,其中将包含valueOfLA静态方法:

public struct LA {
static public func valueOfLA(key: String) -> String? {
    var arguments = NSProcessInfo.processInfo().arguments

    if let index = arguments.indexOf(key) where index + 1 < arguments.count {
        return arguments[index + 1]
    }

    return nil
}

So based on the value which you supply you can execute set of tests and skip the ones which you don't want. 因此,根据您提供的值,您可以执行一组测试,而跳过不需要的测试。 You can also set multiple values and modify the valueForLA method to handle it. 您还可以设置多个值并修改valueForLA方法来处理它。

it is now possible with possible with xcode 8. Check this video 现在可以通过xcode 8实现。观看此视频

https://developer.apple.com/videos/play/wwdc2016/409/ . https://developer.apple.com/videos/play/wwdc2016/409/

在此处输入图片说明

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

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