【发布时间】:2016-10-22 15:08:21
【问题描述】:
我有一个黄瓜功能,可以检查网站是否正确处理了付款文件(BACS、SEPA、FPS 等)。该过程的第一阶段是创建支付文件,然后在数据库中创建预期结果数据。然后使用此数据验证支付处理网站。
如果我处理一个文件,我的功能可以完美地验证预期结果。我卡住的地方是我如何让功能运行 (n) 次,具体取决于最初处理的记录/文件的数量。
我已经尝试使用记录计数迭代的“Around”钩子,但没有任何乐趣,看不到如何将它融入大纲场景,现在认为调用该功能的 rake 任务可能会起作用。
任何想法将不胜感激。
以下是该功能的示例:
功能:处理 SEPA 信用转移文件。同日价值付款。
Background:
Given we want to test the "SEPA_Regression" scenario suite
And that we have processed a "SEPA" file from the "LDN" branch
And we plan to use the "ITA1" environment
Then we log in to "OPF" as a "SEPA Department" user
@feature @find_and_check_sepa_interchange @all_rows
Scenario: Receive SEPA Credit Transfer Files for branch
Given that we are on the "Payment Management > Interchanges" page
When I search for our Interchange with the following search parameters:
| Field Name |
| Transport Date From |
| Bank |
| Interchange Reference |
Then I can check the following fields for the given file in the "Interchanges" table:
| Field Name|
| Interchange Reference |
| Transport Date |
| File Name |
| File Format |
| Clearing Participant |
| Status |
| Direction |
| Bank |
When I select the associated "Interchange Id" link
Then the "Interchange Details" page is displayed
更新我已经为该功能实现了嵌套步骤,以便我可以首先调用数据库记录并将每组记录(或至少行 ID)提供给主要功能,如下所示:
功能
@trial_feature
Scenario: Validate multiple Files
Given we have one or more records in the database to process for the "SEPA_Regression" scenario
Then we can validate each file against the system
功能步骤:
Then(/^we can validate each file against the system$/) do
x = 0
while x <= $interchangeHash.count - 1
$db_row = x
# Get the other sets of data using the file name in the query
id = $interchangeHash[x]['id']
file_name = $interchangeHash[x]['CMS_Unique_Reference_Id']
Background.get_data_for_scenario(scenario, file_name)
steps %{
Given that we are on the "Payment Management > Interchanges" page
When I search for our Interchange with the following search parameters:
| Field Name |
| Transport Date From |
| Bank |
| Interchange Reference |
Then I can check the following fields for the given file in the "Interchanges" table:
| Field Name|
| Interchange Reference |
| Transport Date |
| File Name |
| File Format |
| Clearing Participant |
| Status |
| Direction |
| Bank |
When I select the associated "Interchange Id" link
Then the "Interchange Details" page is displayed
看起来有点“黑客”,但它确实有效。
【问题讨论】:
-
嗨米尔顿!欢迎来到堆栈溢出!你能更具体地解释一下这个程序目前是如何工作的吗?也许通过添加您现在使用的代码和一些您希望它如何工作的伪代码?
-
@thesecretmaster - 出于某种原因,最初的 stackoverflow 问题表格被我的公司阻止了,所以我不得不把它写在我的手机上。看起来好像我可以发表评论,所以这里是:这只是一个基本的黄瓜功能,它登录到网站并使用 watir 验证 dom 中的数据。如前所述,如果我只有一张唱片,一切都很好。如果我在数据库中有 2 条记录,我不知道如何让该功能再次处理。
-
为什么一个简单的循环不起作用?
-
@thesecretmaster - 已设法使用功能示例编辑原始问题。看不到我可以在哪里放置循环,每个
Given, When Then功能步骤都需要多次执行,但您不能通过该功能执行此操作。不知道我怎样才能让它“知道”它必须处理 n 次。 -
我很困惑如何/何时/为什么获得 2 条记录,以及为什么不能循环遍历它们
Interchange.all.lengthtimes