2011-02-09 67 views
6

我有這個問題Cucumber scenarios for extremely long work flow黃瓜背景和持續存在的場景(或先決條件)

而現在我已經爲每個一長串的多部分形式的步驟寫孤立的場景。我有一個Background部分,設置每個Scenario。但現在當我運行整個功能時,黃瓜想要爲每個Scenario重複Background。我想測試一個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 

的是,有辦法,要求先前的方案來運行?有沒有辦法只運行一次Background

+1

我想你可能會讓自己的事情變得比他們需要的更難。您列出的作爲情景的內容代替方案中的步驟。就像Pan提到您鏈接到的問題的答案一樣,您的場景應該是自包含的,並且不需要像這樣有依賴關係。如果是我,我會將背景和場景摺疊回一小部分(最後3個可能會變成1場景),並使用更高級別的步驟,例如「鑑於史蒂夫已完成稿件提交」,並進行驗證那些以確保每一步都有效。 – 2011-02-18 18:44:53

回答

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 

這是工作基本上,除了@load-submission失敗神祕運行的方案,但數據庫加載。所以我必須在沒有標籤的情況下再次運行它。也許有人可以幫助我認清自己。