Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute only specific examples in a Scenario Outline

We're looking to better manage test data using Cucumber in our Java test automation framework. For a Scenario Outline, we're looking to tabulate test parameters categorized by the applicable environment in which they will run. For example,

Scenario Outline: Login into application
Given I am on the homepage in the <environment>
When I enter my <user>
And I enter my <pass>
Then I am taken to the homepage
Examples:
|user    |pass     |environment|
|test    |test1    |local      |
|retest  |retest1  |sit        |
|prodtest|prodtest1|production |

So, when the above scenario is executing in, for example, the SIT environment, only the 2nd example will be picked up, and not the first and third.

Can this level of execution be accomplished?

like image 341
rs79 Avatar asked Nov 16 '25 21:11

rs79


1 Answers

You can get this done by splitting up your examples table into two and using tags on them... Then run the test with the tags to filter in cucumberoptions.

@others
Examples:
|user    |pass     |environment|
|test    |test1    |local      |
|prodtest|prodtest1|production |

@sit
Examples:
|user    |pass     |environment|
|retest  |retest1  |sit        |
like image 161
Grasshopper Avatar answered Nov 18 '25 10:11

Grasshopper