1
votes

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.

2
In gherkin with qaf, new feature of interceptor is coming with next release which will address such requirements.user861594

2 Answers

1
votes

Consider splitting up the examples table into two and using tags on them. Then run the test with the desired tags in cucumberoptions of your runner class to filter them accordingly. If you leave out tags option all tests will run.

    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
votes

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.