Aditya
Aditya

Reputation: 505

cucumber: how to run specific scenario from a feature file

I have multiple scenarios listed in a feature file and I need to run only a single failing scenario (for debugging purposes).

I have mentioned @tag before the scenario but while in Test Runner file when given this tag it is running entire feature file. Please help me out how to put it correctly.

TEST Runner file -

tags={"@Islamic_User_check"},

Upvotes: 30

Views: 97966

Answers (4)

javaPlease42
javaPlease42

Reputation: 4963

If you use IntelliJ then I suggest installing the Cucumber for Java plugin.

enter image description here

Then you can right-click on the Test annotation in the feature file and run that single test scenario.

enter image description here

Upvotes: 16

Use the --name REGEXP command line argument to run only the scenarios that match the regular expression REGEXP:

cucumber --name "Islamic_User_check"

Upvotes: 4

JohnP2
JohnP2

Reputation: 2167

Update: there is now a tags options

cucumber --tags @tagname

In maven:

 mvn test -Dcucumber.options="--tags @tagname"

(and in Windows powershell escape the -D with a backtick)

 mvn test `-Dcucumber.options="--tags @tagname"

Upvotes: 24

Runningriot
Runningriot

Reputation: 743

If you want to run a specific scenario using cucumber you need to provide the line number the scenario starts on like:

cucumber features/test.feature:7

if you use the @ feature it should point to a txt file where the line number is still given.

Source: https://www.relishapp.com/cucumber/cucumber/docs/cli/run-specific-scenarios

Hope this helps

Upvotes: 36

Related Questions