0

Is there a way to run cucumber feature file in java without using the cucumber API annotations?

I need to modify the feature file in my code before running it.

Ghayth
  • 894
  • 2
  • 7
  • 18
  • I'm struggling to understand the usecase for programmatically modifying a feature file before running it. This makes no sense to me. – Dave Newton Jan 26 '17 at 13:31
  • The thing is, I have "composite commands", which are other small feature files that may be included in different places in the main feature file. So at run-time, I want to replace something like "COMPOSITE_COMMAND" with the contents of a feature file named "COMPOSITE_COMMAND.feature". – Ghayth Jan 26 '17 at 13:37
  • Why does this need to be done with source-level manipulation? – Dave Newton Jan 26 '17 at 13:38
  • I've really found no way that cucumber files allow me to use composite commands, do you know if they support that? – Ghayth Jan 26 '17 at 13:39
  • How about first manipulating the feature file outside cucumber, a parser program, and then running it using cucumber? – Grasshopper Jan 26 '17 at 13:58
  • That's the point, how do I run a specific file from java without using cucumber annotations? – Ghayth Jan 26 '17 at 14:06

1 Answers1

3

There is no support from Cucumber for solving the use case you describe.

It sounds to me that you would like to take some time to think about what you are using the features for. Are you using them as a mean of communication and discussion about the system you are working on? Or are you using them as a way to automate testing?

If you are using them for communication, I have a hard time to understand your use case.

If you are using them for scripting automated tests, then I can understand that there might be a need for manipulating them. But if that is your case, I would consider moving to a test framework rather than breaking your back trying to use Cucumber for something it isn't meant to be used for.

Thomas Sundberg
  • 4,098
  • 3
  • 18
  • 25
  • I'm using it to automate test scripts, and I think it's so weird that I can't reuse feature files inside other feature files, I mean it's common sense that this got to be supported right? – Ghayth Jan 29 '17 at 10:08
  • 1
    You are right if Cucumber was meant to be used as a test runner. Since it isn't, features will never be possible to call from other features. Your only options are to push re-use down the stack or use another tool. – Thomas Sundberg Feb 01 '17 at 17:48