相关疑难解决方法(0)

重复使用黄瓜步骤

我想重用一些Cucumber步骤,但似乎找不到正确的方法.

我想写一个像这样的步骤:

Given /^I login with (.*) credentials$/ |type|
  # do stuff with type being one of "invalid" or "valid"
end
Run Code Online (Sandbox Code Playgroud)

但是又有另一个步骤:

Given /^I login successfully$
  # call "Given I login with valid credentials"
end
Run Code Online (Sandbox Code Playgroud)

因此在测试用户身份验证时我可以使用前者,但大多数其他地方,我可以使用后者,而不是实际上必须重新编码.

有没有办法调用其他步骤,或者我只是将逻辑放在辅助方法中,并从每个任务调用所述方法(基本上是一个方法提取重构,在阅读我的问题后让我相信这实际上是最好的方法无论如何)?

ruby testing cucumber

103
推荐指数
4
解决办法
4万
查看次数

是否可以将某个功能重新用作另一个功能的"给定"?

是否可以将某个功能重新用作另一个功能的"给定"?

或者我正在尝试做一些我不应该做的事情

基本上我的功能看起来像:

Scenario: Creating a basic account with valid details (happy path)
  Given I am on the "signup" page
  And I enter all the right details #this is shortened of about 20 steps for your reading ease
  When I press the button labelled "Sign up"
  Then I should see the text "Thanks for signing up"
  And I should have an email from "confirmation@mysite.com" titled "Confirm your account Michael"
  And the database should contain a record for the user marked …
Run Code Online (Sandbox Code Playgroud)

cucumber gherkin

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

cucumber ×2

gherkin ×1

ruby ×1

testing ×1