Can features be called from other features in Cucumber?

天涯浪子 提交于 2020-01-14 19:38:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/23832979/can-features-be-called-from-other-features-in-cucumber

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!