Search code examples
javaeclipseintellij-ideacucumbercucumber-jvm

Running selective tests from Cucumber BDD Example Section


Is there any way to run selective tests from Cucumber BDD Example section without commenting the lines?

For instance, from the example below, I would like to run 2nd row of test without commenting 1st & 3rd rows.

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     |

I was working with C# - SpecFlow where I could achieve this using Test Explorer window. With SpecFlow & MS Visual Studio Test Explorer, user would be able to load all the tests and run single / selective tests easily. So would like to find similar option in Cucumber Java as well. Please help.


Solution

  • In ruby cukes I think you can run test2 by telling cukes the line number of the example. So lets say the scenario is called foo, and the line your test2 example is on is line 25 then

    cucumber features/foo.feature:25

    would do what you ask.