16

I have a simple problem - I want to run a single Cucumber scenario, but I can't seem to find any option/configuration for that.

I have 5-6 scenarios and I can set up configurations to run all tests, but It takes too much time, when I am correcting one scenario...

user3651806
  • 161
  • 1
  • 1
  • 3

5 Answers5

16

Tag the feature file with any name, you may add multiple tags separated with spaces.

Eg : @acceptance @regression

Now, add below options in the end of VM otions by editing configuration

-Dcucumber.options="--tags @acceptance"

Run the test and it will only trigger the feature files tagged with @acceptance

You can either set the configuration one for acceptance and one for regression or edit the configuration everytime you run it.

rpax
  • 4,468
  • 7
  • 33
  • 57
  • Where can I find VM options? Can you please explain it to me like I'm five and dumb? (I'm totally new to Java, Cucumber and Intellij :() – user3651806 May 23 '14 at 09:35
4

Right click the scenario line in your feature file, there will be a Run 'Scenario: My scenario' option.

At least in IntelliJ 2019

Clouren
  • 372
  • 1
  • 3
  • 10
2

You can specify a scenario as a run argument, either though Intellij or at the command line:

As jhilan mentions - In Ruby the command looks like this:

cucumber path/to/file.feature:33

In cucumber-jvm, it looks like this:

-Dcucumber.options="classpath:<package-path>/<file>.feature:<line>"

E.g -Dcucumber.options="classpath:com/company/my_feature.feature:6"

To set this up in Intellij, take a look at their docs on the subject of run configurations

I know this is an old post but it's still the second highest Google result when search "executing cucumber by scenario". So I thought it deserved a more thorough answer.

ADP
  • 136
  • 1
  • 6
0

you can call single Scenario by calling it line number simply assuming your Scenario starts on line

-16 Scenario: description
Given: etc

you can run it like this

cucumber features\test.feature:16

jhilan
  • 156
  • 5
0

This question is quite old now. If you're using cucumber-jvm nowadays, the parameter to use is now:

-Dcucumber.features=path/to/file.feature

More config options here: https://cucumber.io/docs/cucumber/api/#junit

spmason
  • 4,048
  • 2
  • 24
  • 19