开发者

Cucumber Background and persisting Scenarios (or prerequisites)

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜