运行 来自 Cucumber BDD 示例部分的选择性测试

Running selective tests from Cucumber BDD Example Section

有什么方法可以 运行 从 Cucumber BDD 示例部分进行选择性测试而不注释这些行吗?

例如,在下面的示例中,我想 运行 测试第 2 行而不注释第 1 行和第 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 window 实现此目的。使用 SpecFlow 和 MS Visual Studio 测试资源管理器,用户将能够轻松加载所有测试和 运行 单个/选择性测试。所以也想在 Cucumber Java 中找到类似的选项。请帮忙

考虑将示例 table 分成两部分并在其上使用标签。然后 运行 在 运行 和 class 的 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     |

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

cucumber features/foo.feature:25

会按照你的要求去做。