Cucumber 是否可以将某个功能重新用作;给定;为了另一个功能?
是否可以将一个功能重用为另一个功能的“给定”功能 还是我想做一些我不该做的事 基本上,我的功能如下所示:Cucumber 是否可以将某个功能重新用作;给定;为了另一个功能?,cucumber,gherkin,Cucumber,Gherkin,是否可以将一个功能重用为另一个功能的“给定”功能 还是我想做一些我不该做的事 基本上,我的功能如下所示: 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
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 as unconfirmed
Scenario: Confirming account via email
Given I have created a basic account
When I open the confirmation email and visit the url to confirm the account
Then I should be logged in
And the database should contain a record for the user makred as confirmed
我清除我的数据库后,每个功能,因为他们都应该能够单独运行
我走错方向了吗
谢谢你解决了这个问题
您实际尝试的是重用场景。这是黄瓜的
除了此方法的其他问题外,您的测试将更加缓慢和相互依赖,因为您将:
或者,如果您的大多数测试都是在现有帐户上进行的,请使用已经存在的正确用户装置设置默认数据集。对于将要测试帐户创建的有限子集,只需添加一个驱动用户删除的 如果您使用的是Javascript,我通过以下操作创建了一个名为调用场景的包:
Given the scenario "@scenario_tag"
或者创建小黄瓜变量
Given the variable "$variable_name" is equal to
"""
#JSON object
"""
或者创建场景函数并通过执行以下操作调用它们
Given the scenario "@$scenario_function_tag" where variable "$variable_name" is "value_to_replace"
还有更多…目前,您可以使用以下方法:
Background:
Given Some common setup
And Some more setup
Scenario: one
When setup1
Then something1
Scenario: two
When setup2
Then something2
可能重复:@JonM有关相关问题的链接很好。然而,虽然最终的答案是相似的,但我认为问题略有不同。您提到的问题是关于共享块的,而这个问题是关于从特性调用特性的——Cumber曾经明确支持这一点,但现在不再支持了。
Background:
Given Some common setup
And Some more setup
Scenario: one
When setup1
Then something1
Scenario: two
When setup2
Then something2