有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

bdd在Java中运行Cucumber时修改CucumberOptions标记

我想知道在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 {

}

不确定黄瓜是否可以,但我想问问


共 (2) 个答案

  1. # 1 楼答案

    使用标签列表怎么样

    tags = "@Smoke,@Login"
    
  2. # 2 楼答案

    可以使用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