如何使用OR和多个标签运行Cucumber

时间:2014-05-28 15:58:36

标签: cucumber cucumber-jvm

我有黄瓜情景和例子。示例分为使用多个标记,如下所示:

Feature: ...
  Scenario Outline: ...
    ...    
    @Admin @INT
      Examples:
      ...    
    @Admin @EXT
      Examples:
      ...
    @User @EXT
      Examples:
      ...
    @User @INT
      Examples:
      ...

使用代码@Admin@EXT运行方案我使用

...tags = {"@Admin","@EXT"}...

如何使用

运行方案

{"@Admin","@EXT"}&& {"@User","@INT"}{"@Admin","@EXT"} || {"@User","@INT"}

1 个答案:

答案 0 :(得分:6)

此更改已引入cumming-jvm 2.0.0(2017-08-29)

支持Tag Expressions(#1035BjörnRasmusson的一部分)

Migrating from old style tags
--tags @dev stays the same
--tags ~@dev becomes --tags 'not @dev'
--tags @foo,@bar becomes --tags '@foo or @bar'
--tags @foo --tags @bar becomes --tags '@foo and bar'
--tags ~@foo --tags @bar,@zap becomes --tags 'not @foo and (@bar or @zap)'

所以也许是这样的:

-Dcucumber.options="--tags '(@Admin and @EXT) or (@User and @INT)'"

编辑

对于@CucumberOptions,以上内容类似于:

tags = {"@tag"}不变

tags = {"~tag"}变为tags = {"not tag"}

tags = {"@tag1,@tag2")变为tags = {"@tag1 or @tag2"}

tags = {"@tag1","@tag2"}变为tags = {"@tag1 and @tag2"}

tags = {"@tag1","@tag2,@tag3"}变为tags = {"@tag1 and (@tag2 or @tag3)"}