如何使用后台声明中黄瓜场景中提到的示例

发布于 2025-01-15 00:19:23 字数 751 浏览 3 评论 0原文

目的是使用场景中提到的示例在功能文件中的后台给定语句中使用。

以下是供参考的功能文件

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

日久见人心 2025-01-22 00:19:23

据我所知,您不能在后台使用示例中的变量。在您的示例中,如果您需要不同的登录名,则需要在实际场景中执行此步骤。

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.

沩ん囻菔务 2025-01-22 00:19:23

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文