根据标签运行黄瓜测试

时间:2020-03-18 12:41:34

标签: tags automated-tests cucumber logic cucumber-java

我正在尝试根据测试用例的标签运行一些黄瓜测试。

@CucumberOptions(
        features = {"src/test/resources/features"},
        glue = {"<glue value>"},
        plugin = {"pretty", "json:target/cucumber-json-reports/monitor-cucumber-report.json"},
        tags =
                {
                        "@monitor",
                        "not @_ignore",
                        "not @under_construction"
                }
)
public class MonitorCucumberTests extends AbstractTestNGCucumberTests {}

其他文件:

@CucumberOptions(
        features = {"src/test/resources/features"},
        glue = {"<glue value>"},
        plugin = {"pretty", "json:target/cucumber-json-reports/monitor-cucumber-report.json"},
        tags =
                {
                        "@monitor",
                        "not @_ignore",
                        "not @under_construction",
                        "not @<none_monitor_feature>"
                }
)
public class MonitorCucumberTests2 extends AbstractTestNGCucumberTests {}

功能文件:

@monitor @verification @hourly
Feature: Verification flow

  Scenario Outline: Verification happy flow
    Given stuff
    When do stuff


@monitor @verification @hourly @<none_monitor_feature>
Feature: Verification flow with extra

  Scenario Outline: Verification happy flow with extras
    Given stuff
    When do stuff with extra

如果我使用MonitorCucumberTests运行,它将按预期运行两个测试用例。 如果我使用MonitorCucumberTests2运行,它仍然运行两个测试用例。

我不知道如何使用@monitor运行测试用例,但前提是它没有任何其他标签

1 个答案:

答案 0 :(得分:0)

问题是我确实设置了一个变量,所以我使用MonitorCucumberTests2来运行。