(Cucumber) 前置条件导致的长场景
(Cucumber) Long Scenarios caused by pre-conditions
我必须编写一个 Gherkin 场景 (C# Specflow),它在测试之前有一个很大的前提条件 运行 并且想知道什么是最好的方法。我必须完成表单上的多个字段并将其保存并记录创建的表单编号。然后我必须做完全相同的事情并创建第二个表格。
该场景的主要目的是测试关联 2 个已完成表单的新函数。
我认为最好的方法是将前期工作作为背景:
Background: Create Form Documents
Given I have logged into the System
And I have accessed the new <formType1> screen
When I complete all the mandatory <formType2> fields
And press the Save button
Then the new document number will be created
Examples:
| formType1 | formType2 |
| Building Certificate | Building Certificate |
| Building Certificate | Building Certificate |
那么场景就是:
Scenario:
Given that I have accessed the "CHILD DOCUMENT NUMBER" screen
When I select "ASSOCIATE FORM DOCUMENTS" from the menu
And click the "ADD PARENT FORM DOCUMENT" button
And I enter the "PARENT SAFETY DOCUMENT NUMBER" in the Search field
And click on the "SEARCH" button
And click the "SELECT" button
Then the diagram should show "PARENT DOCUMENT NUMBER" as a parent of "CHILD DOCUMENT NUMBER"
我读到在场景之间传递数据是个坏主意,那么最好的方法是将所有这些都集中到一个场景中,该场景实际上将执行两次后台步骤,然后是主场景吗?我正在尝试重用现有步骤并使场景简短明了。对正确方法有什么建议吗?
Given I have two “Building Certificate” document numbers
When I associate the child document with the parent document
Then the parent safety document diagram should show the association
在此,您将编写创建两个文档的方法,并将文档编号分配给一个数组变量。
关联的时候,把第一个作为parent关联到第二个
这样,您只需完成一个场景。
我必须编写一个 Gherkin 场景 (C# Specflow),它在测试之前有一个很大的前提条件 运行 并且想知道什么是最好的方法。我必须完成表单上的多个字段并将其保存并记录创建的表单编号。然后我必须做完全相同的事情并创建第二个表格。
该场景的主要目的是测试关联 2 个已完成表单的新函数。
我认为最好的方法是将前期工作作为背景:
Background: Create Form Documents
Given I have logged into the System
And I have accessed the new <formType1> screen
When I complete all the mandatory <formType2> fields
And press the Save button
Then the new document number will be created
Examples:
| formType1 | formType2 |
| Building Certificate | Building Certificate |
| Building Certificate | Building Certificate |
那么场景就是:
Scenario:
Given that I have accessed the "CHILD DOCUMENT NUMBER" screen
When I select "ASSOCIATE FORM DOCUMENTS" from the menu
And click the "ADD PARENT FORM DOCUMENT" button
And I enter the "PARENT SAFETY DOCUMENT NUMBER" in the Search field
And click on the "SEARCH" button
And click the "SELECT" button
Then the diagram should show "PARENT DOCUMENT NUMBER" as a parent of "CHILD DOCUMENT NUMBER"
我读到在场景之间传递数据是个坏主意,那么最好的方法是将所有这些都集中到一个场景中,该场景实际上将执行两次后台步骤,然后是主场景吗?我正在尝试重用现有步骤并使场景简短明了。对正确方法有什么建议吗?
Given I have two “Building Certificate” document numbers
When I associate the child document with the parent document
Then the parent safety document diagram should show the association
在此,您将编写创建两个文档的方法,并将文档编号分配给一个数组变量。
关联的时候,把第一个作为parent关联到第二个
这样,您只需完成一个场景。