gpt4 book ai didi

ruby-on-rails - Cucumber 背景和持久化场景(或先决条件)

转载 作者:行者123 更新时间:2023-12-04 07:31:08 24 4
gpt4 key购买 nike

我有这个问题Cucumber scenarios for extremely long work flow

现在,我一直在为一长串的多部分表单步骤中的每一个编写孤立的场景。我有一个 Background设置每个 Scenario 的部分.但是现在当我运行整个功能时, cucumber 想重复 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

有没有办法要求运行以前的场景?有没有办法运行 Background只有一次?

最佳答案

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

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神秘地无法运行场景,但数据库已加载。所以我必须在没有标签的情况下再次运行它。也许有人可以帮我弄清楚自己的想法。

关于ruby-on-rails - Cucumber 背景和持久化场景(或先决条件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4951722/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com