4

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.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
user2869231
  • 1,431
  • 5
  • 24
  • 53

1 Answers1

5

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:

Maybe you can restructure your problem to use one of these methods.

Community
  • 1
  • 1
Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
  • I might be able to use the step calls somewhere else, but it wouldn't fit what I'm trying to do right now. A problem I'm having is that I can't get a file to work if I put multiple scenario outlines in it. The order I'm writing the sections is: Assets, Feature, Scenario Outline, Examples, Scenario Outline, Examples. Do I need to write this in a different order or something? The first scenario outline runs fine, but once it gets to the second, it just prints out the first row of the examples and then says that it skips the outline – user2869231 May 27 '14 at 19:18
  • The structure of your feature file sounds right. I suggest starting another question and putting your feature file in so everyone can take a look. – Dave Schweisguth May 27 '14 at 19:34
  • +1 for the link to http://stackoverflow.com/questions/918066/reuse-cucumber-steps which is probably what a lot of people here are looking for – emery May 20 '15 at 21:45