从Cucumber BDD示例部分运行选择性测试

时间:2018-04-13 01:31:45

标签: java eclipse intellij-idea cucumber cucumber-jvm

有没有办法从Cucumber BDD示例部分运行选择性测试而不对行进行注释?

例如,从下面的示例中,我想在没有评论第一和第二的情况下运行第二行测试。第3行。

Scenario Outline: Test Scenario
        Given logged into the test application  using <username> and <password>
        When user is navigated to home screen
        Then user should be able to find home menus

    Examples:
    | username | password |
    | test1    | pwd1     |
    | test2    | pwd2     |
    | test3    | pwd3     |

我正在使用C# - SpecFlow,我可以使用Test Explorer窗口实现此目的。使用SpecFlow&amp;在MS Visual Studio测试资源管理器中,用户可以轻松加载所有测试并运行单个/选择性测试。所以想在Cucumber Java中找到类似的选项。请帮忙。

2 个答案:

答案 0 :(得分:1)

考虑将示例表拆分为两个并在其上使用标记。然后在您的跑步者类的cucumberoptions中使用所需的标签运行测试,以相应地过滤它们。如果省略标签选项,则所有测试都将运行。

    Scenario Outline: Test Scenario
        Given logged into the test application  using <username> and <password>
        When user is navigated to home screen
        Then user should be able to find home menus

    @RunSecond
    Examples:
    | username | password |
    | test2    | pwd2     |

    @RunOthers
    Examples:
    | username | password |
    | test1    | pwd1     |
    | test3    | pwd3     |

答案 1 :(得分:1)

在ruby cukes中我认为你可以通过告诉cukes示例的行号来运行test2。因此,假设场景称为foo,test2示例所在的行是第25行,然后

cucumber features/foo.feature:25

会做你要求的。