可以从黄瓜的其他功能调用功能吗? [英] Can features be called from other features in Cucumber?
问题描述
我想创建一个将调用其他要素文件的要素文件。这可能吗?例如,我想要一个高级功能文件,说这样的东西(只有正确的格式):
调用feature1
call feature2
call feature3
,每个调用都会转到包含,例如:
场景概述:
给定此
然后
和更多
因此,使用此示例,您将拥有1个高级功能文件,3个低级功能文件。
每个子功能可能都是一个场景大纲。
<
没有可以从另一个功能运行功能的黄瓜功能。您甚至不能从另一个场景调用场景。 (你可以在早期版本的Cucumber中这样做,但它已被删除。)
然而,您可以通过几种方式共享场景中的步骤列表: p>
-
您可以在特性文件中的每个场景之前运行一系列步骤,将它们放在Background部分中: https://www.relishapp.com/cucumber/cucumber/docs/background
-
您可以编写一个高级步骤,调用低级步骤列表:重复使用黄瓜步骤
也许你可以重构你的问题,方法。
I want to create a feature file that will call other feature files. Is this possible? For example, I'd like a high level feature file that says something like this (only in proper formatting):
call feature1
call feature2
call feature3
and each call goes to a feature file containing, for example:
Scenario Outline:
Given this
Then that
And more
So with this example, you'd have 1 high level feature file, with 3 lower level feature files. Each sub-feature will probably be a scenario outline.
Thanks.
There is no Cucumber feature that allows you to run a feature from another feature. You can't even call a scenario from another scenario. (You could do that in early versions of Cucumber, but it was removed.)
You can share lists of steps among scenarios in a couple of ways, however:
you can run a list of steps before every scenario in a feature file by putting them in the Background section: https://www.relishapp.com/cucumber/cucumber/docs/background
you can write a high-level step that calls a list of low-level steps: Reuse cucumber steps
Maybe you can restructure your problem to use one of these methods.
这篇关于可以从黄瓜的其他功能调用功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!