gpt4 book ai didi

java - 如何在 Java 中动态设置 CucumberOptions

转载 作者:行者123 更新时间:2023-12-02 09:55:42 24 4
gpt4 key购买 nike

我正在开发一个桌面应用程序,它将执行自动化测试用例。用户可以从 GUI 选择执行类型:按功能/按场景/按标签名称。现在我使用 maven 并在 CMD 中执行命令来执行测试用例,我想切换到 TestNG 执行,但我需要从配置文件动态设置 CucumberOptions,

@CucumberOptions(features = { "src/test/resources/features/" }, tags = { "@Test3" }, glue = { "stepdefinitions" }, plugin = { "listeners.ExtentCucumberFormatter:" })
public class TestNGRunner extends AbstractTestNGCucumberTests {
}

但是 CucumberOptions 需要一个常量表达式,我无法设置它们。

有什么办法可以做到吗?

最佳答案

您可以通过命令行参数传递 Cucumber 选项:

You can list the options available for the Cucumber version you are using.

Pass the --help option to print out all the available configuration options:

java cucumber.api.cli.Main --help

Or:

mvn test -Dcucumber.options="--help"

You can also use tags to specify what to run.

Configuration options can also be overridden and passed to any of the runners via the cucumber.options Java system property.

For example, if you are using Maven and want to run a subset of scenarios tagged with @smoke:

mvn test -Dcucumber.options="--tags @smoke"

provide additional mechanisms for passing options to Cucumber.Some of the runners

Cucumber Options Documentation

关于java - 如何在 Java 中动态设置 CucumberOptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56025493/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com