Cucumber:在每次执行场景大纲之前,后台是否运行?

Cucumber:在每次执行场景大纲之前,后台是否运行?,cucumber,gherkin,Cucumber,Gherkin,给定如下所示的功能文件: Feature: Coffee improves mood in the background Background: Given the user drank coffee Scenario Outline: Coffee changes peoples moods Then user <USER> should be <MOOD> Examples: | USER | MOOD

给定如下所示的功能文件:

Feature: Coffee improves mood in the background

  Background:
    Given the user drank coffee

  Scenario Outline: Coffee changes peoples moods
    Then user <USER> should be <MOOD>

    Examples:
      | USER     | MOOD         |
      |  Michael |  happy       |
      |  Elvis   |  electrified |
      |  John    |  sad         |
功能:咖啡改善背景情绪
背景:
假设用户喝了咖啡
情景概述:咖啡改变人们的情绪
那么用户应该是
示例:
|用户情绪|
|迈克尔|高兴吗|
|埃尔维斯|电气化|
|约翰·萨德|

背景测试步骤“用户喝了咖啡”应该运行1次还是3次?

看看下面的人为答案。在输出中,您将看到后台步骤执行了3次

feature.rb:

Feature: Does a background run before each scenario outline?

  Background:
    When I'm a background step

  Scenario Outline: foo
    Then I should print '<count>'

    Examples:
      |count|
      | 10  |
      | 20  |     
      | 30  |   
输出:

Feature: Does a background run before each scenario outline

BACKGROUND EXECUTED  Background:                  # features/login.feature:3
    When I'm a background step # features/step_definitions/login.rb:1

  Scenario Outline: foo           # features/login.feature:6
    Then I should print '<count>' # features/login.feature:7

    Examples:
      | count |
      | 10    |
BACKGROUND EXECUTED      | 20    |
BACKGROUND EXECUTED      | 30    |

3 scenarios (3 passed)
6 steps (6 passed)  
功能:在每个场景大纲之前是否运行后台
后台执行后台:#功能/登录。功能:3
当我是后台步骤#features/step#u definitions/login.rb:1
场景大纲:foo#功能/登录。功能:6
然后我应该打印“”#功能/登录。功能:7
示例:
|计数|
| 10    |
背景执行| 20|
背景执行| 30|
3个场景(3个通过)
6个步骤(通过6个步骤)

谢谢,非常感谢。最重要的是,现在这一现象已被记录在案!
Feature: Does a background run before each scenario outline

BACKGROUND EXECUTED  Background:                  # features/login.feature:3
    When I'm a background step # features/step_definitions/login.rb:1

  Scenario Outline: foo           # features/login.feature:6
    Then I should print '<count>' # features/login.feature:7

    Examples:
      | count |
      | 10    |
BACKGROUND EXECUTED      | 20    |
BACKGROUND EXECUTED      | 30    |

3 scenarios (3 passed)
6 steps (6 passed)