仅在“方案大纲”中执行特定示例 [英] Execute only specific examples in a Scenario Outline

查看:130
本文介绍了仅在“方案大纲”中执行特定示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望在我们的Java测试自动化框架中使用Cucumber更好地管理测试数据。对于方案概述,我们正在查看根据其将运行的适用环境分类的测试参数。
例如,

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?

推荐答案

您可以将示例表拆分为两个并使用标签来完成此操作...然后运行测试

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        |

这篇关于仅在“方案大纲”中执行特定示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆