ruby-on-rails – 非常长的工作流程的黄瓜场景

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 非常长的工作流程的黄瓜场景前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们需要为一个功能测试一个漫长的步骤.从登录到许多模式对话框,多步骤表单和不同角色的用户都可以进行交互.我们如何将这个过程的一部分分解为单独的场景?

这是一个例子:

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"

等等几十种场景等等.问题是每个场景都是基于最后一个场景.如何在不重复以前所有场景的情况下单独测试每个场景?

解决方法

场景应该是自包含的,因此您可以创建一个设置后台进程,设置一个可以在不同场景中使用的基本手稿:
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"
原文链接:https://www.f2er.com/ruby/269867.html

猜你在找的Ruby相关文章