仅执行场景大纲中的特定示例示例、大纲、场景

2023-09-08 00:00:38 作者:傷、不過如此

我们希望在我们的 Java 测试自动化框架中使用 Cucumber 更好地管理测试数据.对于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 |

因此,当上述场景在例如 SIT 环境中执行时,只会选择第二个示例,而不是第一个和第三个.

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?

推荐答案

您可以通过将示例表分成两个并在它们上使用标签来完成此操作...然后使用标签运行测试以过滤 cucumberoptions.

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        |