问题
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