Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cucumber: how to run specific scenario from a feature file

Tags:

java

cucumber

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"},
like image 796
Aditya Avatar asked Dec 03 '16 06:12

Aditya


People also ask

How do I only run certain tags in Cucumber?

Tag starts with “@”. After “@” you can have any relevant text to define your tag like @SmokeTests just above the scenarios you like to mark. Then to target these tagged scenarios just specify the tags names in the CucumberOptions as tags = {"@SmokeTests"}.

How do you run multiple scenarios in a single feature file?

You can execute multiple scenarios in a single or multiple feature file by tagging Scenarios with common tags or grouping them using the rule keyword and tags. And Later, you can execute the scenarios by using that tag in the Cucumber Runner or Command line.


2 Answers

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

like image 163
Runningriot Avatar answered Sep 24 '22 17:09

Runningriot


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"
like image 44
JohnP2 Avatar answered Sep 22 '22 17:09

JohnP2