Execute only specific examples in a Scenario Outline

旧时模样 提交于 2020-01-11 06:36:05

问题


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?


回答1:


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        |



回答2:


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.



来源:https://stackoverflow.com/questions/40131538/execute-only-specific-examples-in-a-scenario-outline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!