如何仅根据黄瓜中的标签运行选定的场景?

时间:2021-01-13 06:07:15

标签: cucumber

我的功能文件中有如下场景:

@tag1
Scenario1

@tag2 @tag1
Scenario2

@tag3 @tag1
Scenario3

所以我想执行只有@tag1 的场景1,但不想执行场景2 和场景3。如何做到这一点。

我尝试过以下选项:

-Dcucumber.options='--tags "((@tag1) and (not @tag2 or not @tag3)"'

但它正在执行所有 3 个场景。

1 个答案:

答案 0 :(得分:0)

从 Cucumber v6 开始,您不能再将 cucumber.options 与字符串之类的命令行一起使用。相反,您必须使用单独的属性。

mvn test -Dcucumber.filter.tags="(@cucumber or @gherkin) and not @salad"

来自:https://github.com/cucumber/cucumber-jvm/tree/main/core#properties-environment-variables-system-options