我通常有诸如“成功创建...”之类的场景来测试成功案例(您填写所有必填字段,所有输入均有效,您确认,最后真正保存)。我不认为您可以轻松地为单个字段定义单独的场景,因为通常成功创建的场景需要“同时”满足几个其他条件(例如,必须填写所有必填字段)。
例如:
Scenario: Successful creation of a customer
Given I am on the customer creation page
When I enter the following customer details
| Name | Address |
| Cust | My addr |
And I save the customer details
Then I have a new customer saved with the following details
| Name | Address |
| Cust | My addr |
稍后我可以在这个场景中添加额外的字段(例如账单地址):
Scenario: Successful creation of a customer
Given I am on the customer creation page
When I enter the following customer details
| Name | Address | Billing address |
| Cust | My addr | Bill me here |
And I save the customer details
Then I have a new customer saved with the following details
| Name | Address | Billing address |
| Cust | My addr | Bill me here |
当然,您必须定义或扩展与新字段相关的更多场景(例如验证等)。
I think if you take this approach you can avoid having a lot of "trivial" scenarios. And I can argue that this is the success case of the "create customer feature", which deserves a single test at least.