Cucumber scenarios for extremely long work flow

2020-06-16 03:16发布

We need to test a long process of steps for one Feature. From logging in to many modal dialogs, multi-step forms, and users of different roles all interacting. How can we break parts of this process down into individual Scenarios?

Here is an example:

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"

And so on and so on for dozens of scenarios. The problem is each scenario is built off of the last one. How can I test each scenario in isolation without repeating all of the previous ones?

1条回答
啃猪蹄的小仙女
2楼-- · 2020-06-16 03:40

Scenarios are supposed to be self contained, so you can either create a setup Background process, that setups a basic manuscript that you can use in different scenarios:

Feature: ...
  Background:
    Given a single manuscript exists

  Scenario: ...

  Scenario: ...

  Scenario: ...

If you are really building on the previous step and are entirely dependent upon it, then create a single 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"
查看更多
登录 后发表回答