10

I am trying to set the "name" option for Cucumber to be able to run a specific feature or scenario.

I have entered this,

mvn test -DCucumber.Options--name="MyFeatureName"

but it just runs all the features and doesn't give an error.

Any ideas?

The Cat
  • 2,375
  • 6
  • 25
  • 37

2 Answers2

16

Here is a snippet from the Cucumber-JVM repo on how to run the java-helloworld example by passing cucumber options:

mvn test -Dcucumber.options="--format json-pretty --glue classpath:cucumber/examples/java/helloworld src/test/resources"

Keep in mind that it will override all the options in the @Cucumber.Options annotation you have on "RunCukesTest". I haven't got it to work for my own tests but maybe this will help.

So it looks like you need to give all the options needed to run cucumber, including the java class path and where the code is located using the "--glue" parameter.

Fab
  • 665
  • 3
  • 9
  • 1
    Thanks! I am trying to do "--name Something" to run a specific feature or scenario. I found this didn't work if the feature or scenario you wanted to run has spaces in the name. Would you have to escape spaces in the command line? – The Cat Oct 04 '12 at 08:47
  • Yea I think you would need quotes. If double quotes (") don't work try single quotes ('), you could also try escaping the quotes with a slash or if everything else fails use variable substitution. By variable substitution I mean doing something like this, for example in Linux: export FEATURE_NAME="My Feature With Spaces" mvn test -Dcucumber.options="--name $FEATURE_NAME" ... etc Just some ideas, I'm still trying to get it to work for my particular case :) – Fab Oct 04 '12 at 23:24
  • 1
    I think there is a bug in this area raised a month ago that hasn't been fixed yet, https://github.com/cucumber/cucumber-jvm/issues/379 – The Cat Oct 05 '12 at 08:38
0

Your tests are running in separate JVM, so you need to specify that system property in the test plugin configuration (i.e. surefire or failsafe plugin config in your pom.xml).

Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67