Execute only specific examples in a Scenario Outli

2020-03-25 06:02发布

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?

2条回答
劫难
2楼-- · 2020-03-25 06:37

That is not what scenario outlines are designed for. You can write separate scenario's and then use tags on each one that you can then pass in at runtime which tag you want to run.

查看更多
Viruses.
3楼-- · 2020-03-25 06:55

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        |
查看更多
登录 后发表回答