我是小黄瓜语言的新手,在我看来这似乎是非常基本的问题,但我找不到答案。
我知道可以在 Gherkin 中编写多行步骤参数,如下所示:
Given a blog post named "Random" with Markdown body
"""
Some Title, Eh?
==============
Here is the first paragraph of my blog post. Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
"""
我的问题是关于在多行上编写单步,如下所示:
Given that Gherkin language allows me to write my step definitions \
on multiple lines
Then my test cases would be easier to read :)
在上面的示例中,我使用“\”作为行继续符号。顺便说一句,我尝试了上面的例子并得到了解析器错误。
是的,我们可以使用三组双引号 (""") 在多行上编写 Gherkin 步骤。Gherkin 会将三组双引号识别为多行字符串的边界分隔符并将其传入。无论您编写什么内容三组双引号之间将作为单个字符串传递到您的步骤定义。
在我当前的水豚项目中,我在多行中编写了小黄瓜步骤,如下所示:
Scenario: Some test scenario
Given Bob is on "www.abc.com"
When Bob creates team "Test Team"
Then Bob sees message:
"""
As the Team Captain you will be responsible for paying for the team after
registration closes. You will be emailed instructions at the close of
registration.
"""
And Bob clicks "Next" button
多行小黄瓜步骤的步骤定义:
And(/^(\S*) sees message:$/) do |user, message|
page.should have_content(message)
end
在此我按原样使用了传递的内容。您还可以根据需要拆分内容并使用。
欲了解更多信息,请参阅下面提到的链接:http://asymmetrical-view.com/2011/06/02/cucumber-gherkin-and-multiline-arguments.html http://asymmetrical-view.com/2011/06/02/cucumber-gherkin-and-multiline-arguments.html
希望这可以帮助 :)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)