場景大綱

在某些情況下,你可能想要反覆重新執行相同的場景,替換掉引數。在這種情況下,Gherkin 提供了幾個新的關鍵字來適應這種情況, Scenario Outline:Example : . Scenario Outline 關鍵字告訴 Cucumber,該場景將多次執行,從列表中替換掉引數。在顯式標註列表之前呼叫 Examples 關鍵字。場景大綱的引數應包含在有角度的括號中。在下面的示例中,請注意包含在有角度的括號中的引數名稱對應於示例下列出的列名稱。每列用豎線分隔,第一行的列名稱。

Feature: Product Login
    As a user, I would like to be able to use my credentials to successfully 
    login. 
    
    Rules:
    - The user must have a valid username
    - The user must have a valid password
    - The user must have an active subscription 
    - User is locked out after 3 invalid attempts
    - User will get a generic error message following 
      login attempt with invalid credentials 

    Background: The user starts out on the login page
        Given the user is on the login page

    Scenario Outline: The user successfully logs in with their account
         This scenario outlines tests in which various users attempt
         to sign in successfully 

         When the user enters their <username>
         And the user enters their <password>
         Then the user should be successfully logged on

         Examples:
         | username | password |
         | frank    | 1234     |
         | jack     | 4321     |