1

I am using cucumber-jvm + Junit + Maven to run my test cases . I could not able to find any methods to rerun my failed test cases . I have checked this Rerunning failed cucumber tests using cucumber-jvm . But the workaround does not working fine .

It would be good if you have any other way to rerun the test cases.

1

2 Answers 2

2

See the answer starting with "You can pass cucumber options to mvn as below" in Rerunning failed cucumber tests using cucumber-jvm

The following is copied from the above link based on asker's request

You can pass cucumber options to mvn as below

 mvn clean verify -Dcucumber.options="@rerun.txt" 

Note there is a tricky part here. If you are using the same test runner for both first run and rerun (and I believe that's what you want), then the test runner would contains something like

@CucumberOptions(plugin = { "rerun:target/rerun.txt"}) 

If you fire your rerun with maven using the same rerun file name as below

 mvn clean verify -Dcucumber.options="@target/rerun.txt" 

then cucumber will complain it could not find the rerun file. Why? Because the plugin "rerun:target/rerun.txt" will delete the file first with this test runner.

Workaround is copy/rename the file first, then kick off the mvn run like

mv target/rerun.txt rerun.txt && mvn clean verify -Dcucumber.options="@rerun.txt" 

And this is actually what you want. Because say if there are 5 failed scenarios in file target/rerun.txt. And with the rerun after some fix, 2 of them passed. Now the target/rerun.txt will contain the remaining 3 failed scenarios only, which would be your new start point along the debugging way.

Sign up to request clarification or add additional context in comments.

5 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
Updated - though I think we should avoid duplication.
Does my answer solve your issue? If so, be my first answer adopter please :)
I apologize, but I'm not very familiar with the technology the question uses, so I don't have enough knowledge to vote. Don't worry, though! I'm sure it'll get upvoted soon.
Understood. No worries.
1

Use the rerun plugin to generate a list of scenarios that failed:

java cucumber.api.cli.Main --plugin rerun:rerun.txt features 

This will write the location of each failing scenario to a text file called rerun.txt (you can call it whatever you want). Then you can use the output file as an input to your next run of Cucumber to specify which scenarios should be executed:

java cucumber.api.cli.Main < rerun.txt 

6 Comments

When i run using "java cucumber.api.cli.Main --plugin rerun:rerun.txt features" , it throws error "Error: Could not find or load main class cucumber.api.cli.Main" .FYI , I am using Maven to run the test, "mvn test" .
Just use Maven as usual, but specify the rerun plugin in Cucumber Options
To expand on my previous comment, take a look at groups.google.com/d/msg/cukes/BQ5sb7atomE/4sRu-CzhPC4J which shows use of the rerun plugin from Maven. Note that this is an old example and uses the deprecated 'format' option which has been replaced with the 'plugin' option.
I have used your methods , but i have got the same error . I have run it using "mvn test -Dbrowser="ff" -Dcucumber.options="@rerun.txt"" . then i got , "java.lang.IllegalArgumentException: Not a file or directory: D:\Works\cucumber-junit\@rerun.txt" . Rerun is in my project path . so i changed to "mvn test -Dbrowser="ff" -Dcucumber.options="rerun.txt"" , then i got "cucumber.runtime.CucumberException: Error parsing feature file rerun.txt" . Please help me .
What folder is rerun.txt being generated in?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.