我正在尝试编写多步骤业务流程的需求(通过向导)。我有很多场景,用户与一个屏幕的交互会改变是否允许您在另一个屏幕上选择选项。
例如(我掩盖了实际的业务,但步骤的过程和形式几乎相同):
Feature: Personal Diagnostic Search Filter
In order to select a Technician who offers Personal Diagnostics,
when I've asked for a Personal Diagnostic
As a Business Customer
I want to limit my search to Technicians who offer Personal Diagnostics
Background:
Given a Business named "Big Al's Auto Supply"
And a Customer named "Bob Test" at the "Big Al's Auto Supply" Business
And an Account named "bobtest@testbusiness.com" owned by "Bob Test"
And the "bobtest@testbusiness.com" Account has the "Repair Order Creator"
permission
And you log in as "bobtest@testbusiness.com"
And you start scheduling a new Repair Order
Scenario: Enter the Select Technician page when Use PD is selected
Given you select Use PD
When you enter the Select Technician page
Then the PD Filter should be visible
And the PD Filter should be selected
Scenario: Basic Search for Technicians when PD Filter is selected
Given a Technician named "PD Technician"
And the Technician named "PD Technician" supports PD
And a Technician named "Non-PD Technician"
And the Technician named "Non-PD Technician" does not support PD
And you select Use PD
And you enter the Select Technician page
And you select the PD Filter
And you select Basic Search
When you search for Technicians with the name "Technician"
Then your search results should contain "PD Technician"
And your search results should not contain "Non-PD Technician"
但在Gherkin wiki上,建议您:
避免在给定的情况下谈论用户交互
不过,他们继续例外:
登录一个用户(无交互推荐的一个例外。“发生得更早”的事情是可以的)。
该页面上还说:
When 步骤的目的是描述用户执行的关键操作
如果您有很多 UI 交互,什么属于 Given,什么属于 When?
在我的第一个场景中,select Use PD
需要 UI 交互,因为它是创建新维修订单的向导的一部分。然而,这是 PD 过滤器可见的前提条件,并且在用户进入 Select Technician 页面时触发。
第一种情况可能没有那么糟糕,但第二种情况会加剧问题。当您点击搜索时会触发搜索,但必须完成许多 UI 交互才能导航到该页面。其中一些交互也不能被掩盖,因为Use PD
必须选择搜索过滤器才能出现。但这些 UI 交互并不是场景的关键操作。