黄瓜背景和持久场景(或先决条件)

Ree*_*Law 6 ruby-on-rails cucumber ruby-on-rails-3

我有这个问题Cucumber场景非常长的工作流程

现在,我一直在为一系列多部分表单步骤中的每一步编写孤立的场景.我有一个Background部分设置每个Scenario.但是现在当我运行整个功能时,黄瓜想要重复Background每个功能Scenario.我想测试一个Scenario以前所有的构建.

以下是我的功能的简要概述:

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
Run Code Online (Sandbox Code Playgroud)

是否有办法要求运行以前的方案?还有一种方法Background只运行一次吗?

Ree*_*Law 2

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

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
Run Code Online (Sandbox Code Playgroud)

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