[英]Can features be steps in cucumber?
Let's say I've got a feature called create_account
, which calls a number of steps to create the account. 假设我有一个名为create_account
的功能,该功能调用许多步骤来创建帐户。
Now I want to make a more elaborate feature test where having an account is a really just a step in a bigger scenario. 现在,我想进行一个更复杂的功能测试,其中拥有一个帐户实际上只是更大场景中的一个步骤。 Do I need to recode my original feature as steps or can I call the original feature somehow in my new scenario? 我需要将我的原始功能重新编码为步骤,还是可以在新场景中以某种方式调用原始功能?
You cannot call a feature or scenario from a step. 您不能从一个步骤调用功能或方案。 But probably, what you want can be accomplished using Background (steps that will be executed before every scenario in a feature, see https://github.com/cucumber/cucumber/wiki/Background ): 但是可能,您想要的可以使用Background来完成(将在功能中的每个方案之前执行的步骤,请参阅https://github.com/cucumber/cucumber/wiki/Background ):
Feature: Different ways to create account
Background:
# Some steps to create account
Scenario: Create account
# Nothing
Scenario: Create account and do something
# Something else
Or else, you can pack all the step of the initial scenario into a complex step and use it. 否则,您可以将初始方案的所有步骤打包到一个复杂的步骤中并使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.