Cucumber scenarios for extremely long work flow

偶尔善良 提交于 2019-12-21 04:20:49

问题


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:


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"


来源:https://stackoverflow.com/questions/4902361/cucumber-scenarios-for-extremely-long-work-flow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!