如何使用后台声明中黄瓜场景中提到的示例
目的是使用场景中提到的示例在功能文件中的后台给定语句中使用。
以下是供参考的功能文件
Feature: As a user with a valid credentials i should view awards and select products for cart
Background:
Given an authenticated logged in user with valid <username> and <password>
@smoke
Scenario: Bot should display awards
When the user is checks for award section
Then User is presented with awards earned
Examples:
| username | password |
| username | password |
@smoke
Scenario: bot should select the proper product
When the user chooses product to buy
Then User is presented with cart with selected product.
Examples:
| username | password |
| username | password |
The aim is to use examples mentioned in the scenario to be used in the background given statement in a feature file.
following is the feature file for reference
Feature: As a user with a valid credentials i should view awards and select products for cart
Background:
Given an authenticated logged in user with valid <username> and <password>
@smoke
Scenario: Bot should display awards
When the user is checks for award section
Then User is presented with awards earned
Examples:
| username | password |
| username | password |
@smoke
Scenario: bot should select the proper product
When the user chooses product to buy
Then User is presented with cart with selected product.
Examples:
| username | password |
| username | password |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,您不能在后台使用示例中的变量。在您的示例中,如果您需要不同的登录名,则需要在实际场景中执行此步骤。
Afaik you cannot use variables from your examples in the background. In your example, if you need different logins, you'll need to make that a step in your actual scenario.
Cucumber 不支持后台场景大纲。您需要在场景中定义它,这意味着如果您想要使用场景大纲,则不能在背景中使用该步骤。以下是 Cucumber 团队关于此功能的更新在此处输入链接说明:
https://github.com/cucumber/common/issues/469
Cucumber doesn't support scenario outline in background. You need to define that in the scenario, which means if you want to user scenario outline you can't use that step in Back ground. Here is the update from cucumber team regarding this featureenter link description here:
https://github.com/cucumber/common/issues/469