如何创建处理此嵌套黄瓜表的步骤?
Scenario Outline: Sign Up
Given I am on the <language> site
And I am on the home page
When I follow "<register>"
And I fill in the following:
| <fname> | John |
| <lname> | Doe |
And I check "paintball"
And I fill in the following within Emergency Contact:
| <ename> | Jane Doe |
| <enumber> | 4161111111 |
Then I should see "John Doe"
Examples:
| language | register | fname | lname | ename | enumber |
| en | Register | First Name | Last Name | Name | Number |
| pt | Registrar | Primeiro Nome | Sobrenome | Nome | Telefone |
步骤黄瓜要求我实施
When /^ I fill in "(.*?)" with "(.*?)" $/ do |arg1, arg2, table|
# table is a Cucumber::Ast::Table
pending # express the regexp above with the code you wish you had
end
但是当我实现它时,这会强制导致arity不匹配错误。
Your block takes 3 arguments, but the Regexp matched 2 arguments.
(Cucumber::ArityMismatchError)
这是预期的。在解析特征文件直到结束之前,黄瓜看到该特征具有嵌套表。由于没有这个步骤定义,它要求一个。但是在解析整个文件之后,Gherkin会将功能结束时的表格翻译成单独的占位符,从而无需使用bested表格(或者我认为这样做有效)。
但是,如果我使用两个参数实现前一个When
子句进入范围,我会得到一个模糊错误,--guess
选项没有帮助。
我被困在这条路上太久了。任何帮助表示赞赏。