我们需要为一个功能测试一个漫长的步骤。从登录到许多模式对话框,多步骤表单和不同角色的用户都可以进行交互。我们如何将这个过程的一部分分解为单独的场景?
以下是一个例子:
Scenario: New Manuscript
Given I am on the manuscripts page
When I press "Submit A New Manuscript"
Then I should see "Please specify this manuscript's type"
Scenario: Choose Manuscript Type
Given I am choosing a manuscript type
When I click "Original Paper"
Then I should see "Edit Manuscript Details"
Scenario: Edit Manuscript Details
Given I am editing manuscript details
And I am on the editing page
When I fill in "Manuscript Title" with "Testing Story"
Then I should see "Suggest Reviewers"
依旧等等几十种情景。问题是每个场景都是基于最后一个场景。如何在不重复所有先前场景的情况下单独测试每个场景?
答案 0 :(得分:9)
场景应该是自包含的,因此您可以创建一个设置后台进程,设置一个可以在不同场景中使用的基本手稿:
Feature: ... Background: Given a single manuscript exists Scenario: ... Scenario: ... Scenario: ...
如果您真的在上一步构建并完全依赖它,那么创建一个场景:
Scenario: Manuscript flow Given I am on the manuscripts page When I press "Submit A New Manuscript" Then I should see "Please specify this manuscript's type" Given I am choosing a manuscript type When I click "Original Paper" Then I should see "Edit Manuscript Details" Given I am editing manuscript details And I am on the editing page When I fill in "Manuscript Title" with "Testing Story" Then I should see "Suggest Reviewers"