Cucumber 背景和持续场景(或先决条件)

发布于 2024-10-16 20:26:27 字数 1537 浏览 0 评论 0原文

我遇到了这个问题极长工作流程的黄瓜场景

现在我一直在为一长串多部分表单步骤中的每一个编写单独的场景。我有一个Background 部分来设置每个Scenario。但现在,当我运行整个功能时,cucumber 希望为每个 Scenario 重复 Background。我想测试一个基于所有先前场景构建的场景

这是我的功能的大致轮廓:

Feature: Submit a manuscript
  In order to complete a manuscript submission
  As a corresponding author
  I want to complete the to-do list

  Background:
    Given I am logged in as "Steve"
    And an article_submission "Testing Web Apps" exists
    And "Steve" is a "Corresponding Author" for "Testing Web Apps"
    And I am on the manuscript to-do list page for "Testing Web Apps"

  Scenario: Steve suggests reviewers for his manuscript
    ...
  Scenario: Steve completes the manuscript fees to-do item
    ...
  Scenario: Steve wants to add Barbara as a co-author
    ...
  Scenario: Steve uploads necessary files
    ...
  Scenario: Steve edits the fees page and general information page
    ...
  Scenario: Steve re-uploads the manuscript file
    ...
  Scenario: Steve completes the Copyright Transfer
    ...
  Scenario: Steve completes Author Responsibilities & Agreement
    ...
  # These scenarios depend on all the previous ones having run  
  Scenario: Steve Completes submission
    ...
  Scenario: Steve goes back and make changes
    ...
  Scenario: Steve fills out payment page

是否有办法要求运行以前的场景?有没有办法只运行一次后台

I had this problem Cucumber scenarios for extremely long work flow

And now I've been writing isolated scenarios for each of a long series of multi-part form steps. I have a Background section that sets up each Scenario. But now when I run the entire feature, cucumber wants to repeat the Background for each Scenario. I want to test a Scenario that builds off of all the previous ones.

Here is the bare outline of what my feature looks like:

Feature: Submit a manuscript
  In order to complete a manuscript submission
  As a corresponding author
  I want to complete the to-do list

  Background:
    Given I am logged in as "Steve"
    And an article_submission "Testing Web Apps" exists
    And "Steve" is a "Corresponding Author" for "Testing Web Apps"
    And I am on the manuscript to-do list page for "Testing Web Apps"

  Scenario: Steve suggests reviewers for his manuscript
    ...
  Scenario: Steve completes the manuscript fees to-do item
    ...
  Scenario: Steve wants to add Barbara as a co-author
    ...
  Scenario: Steve uploads necessary files
    ...
  Scenario: Steve edits the fees page and general information page
    ...
  Scenario: Steve re-uploads the manuscript file
    ...
  Scenario: Steve completes the Copyright Transfer
    ...
  Scenario: Steve completes Author Responsibilities & Agreement
    ...
  # These scenarios depend on all the previous ones having run  
  Scenario: Steve Completes submission
    ...
  Scenario: Steve goes back and make changes
    ...
  Scenario: Steve fills out payment page

Is there are way to require previous scenarios to be run? And is there a way of running the Background only once?

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

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

发布评论

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

评论(1

梦里的微风 2024-10-23 20:26:27

我决定将应用程序“冻结”在运行该功能后的状态。我通过添加转储和加载数据库的钩子来做到这一点。

features/support/hooks.rb中,我有:

After('@complete-submission') do
  # Dump the database
  exec "mysqldump -u root --password=### onc_test > #{Rails.root}/support/submission.sql"
end

Before('@load-submission') do
  # Load the database
  exec "mysql -u root --password=### onc_test < #{Rails.root}/support/submission.sql"
end

这基本上可以工作,除了@load-submission神秘地无法运行场景,但数据库已加载。所以我必须在没有标签的情况下再次运行它。也许有人可以帮我解决这个问题。

I decided to "freeze" the application in the state it was immediately after running the Feature. I did this by adding hooks that dump and load the databse.

In features/support/hooks.rb I have:

After('@complete-submission') do
  # Dump the database
  exec "mysqldump -u root --password=### onc_test > #{Rails.root}/support/submission.sql"
end

Before('@load-submission') do
  # Load the database
  exec "mysql -u root --password=### onc_test < #{Rails.root}/support/submission.sql"
end

This is working basically, except the @load-submission fails mysteriously to run the Scenario, but the database is loaded. So I have to run it again without the tag. Maybe someone can help me figure that own out.

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