gpt4 book ai didi

java - 在Java中运行Cucumber时修改CucumberOptions标签

转载 作者:太空宇宙 更新时间:2023-11-04 09:36:58 25 4
gpt4 key购买 nike

我想知道是否有办法在 Cucumber 运行时修改 CucumberOptions 标签?

我不确定这是否可能,但我想知道是否有办法在 Cucumber 运行时修改标签。在我的示例代码中,我想在 Cucumber 运行后添加另一个标签“@Login”。我正在尝试设置一个配置,在其中我可以选择要运行的功能,而无需进入 Runner 类。

设置类

 String AddTags = "@Login";
set = new HashMap<String, String>(){
{put("Tags", AddTags);

运行者

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions (features="src/test/cucumber/features",
tags = "@Smoke", //For instance, once cucumber runs I want to add
tag "@Login". //So something like adding Settings.set.get("Tags");
plugin = {"pretty", "html:target/cucumber-
htmlreport","json:target/cucumber-report.json"}
)
public class Runner {

}

不确定这对于 Cucumber 是否可行,但想问一下。

最佳答案

您可以使用Tag expressions组合多个标签,例如:

**Expression        Description**
@fast Scenarios tagged with @fast
@wip and not @slow Scenarios tagged with @wip that aren’t also tagged with @slow
@smoke and @fast Scenarios tagged with both @smoke and @fast
@gui or @database Scenarios tagged with either @gui or @database

关于java - 在Java中运行Cucumber时修改CucumberOptions标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56399096/

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