极长工作流程的 Cucumber 场景

发布于 2024-10-15 16:54:05 字数 703 浏览 3 评论 0原文

我们需要为一个功能测试一个漫长的步骤过程。从登录到许多模式对话框、多步骤表单以及不同角色的用户都在交互。我们如何将这个过程的各个部分分解为单独的场景?

下面是一个例子:

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"

等等几十个场景。问题是每个场景都是建立在上一个场景之上的。如何单独测试每个场景而不重复前面的所有场景?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2024-10-22 16:54:05

场景应该是独立的,因此您可以创建一个设置后台进程,该进程设置一个可以在不同场景中使用的基本手稿:

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"

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文