场景大纲
在某些情况下,你可能想要反复重新运行相同的场景,替换掉参数。在这种情况下,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 |