serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

Retry failed tests #184

Open qaEng1213 opened 5 years ago

qaEng1213 commented 5 years ago

Is there any opportunity to setup Serenity/Cucumber to rerun failed tests ? What I've tried so far is putting into serenity.properties this params:

test.retry.count=3 max.retries=4 junit.retry.tests=true test.retry.count.cucumber=3

None of them worked. Any ideas?

shreyasarjun commented 5 years ago

Can someone please answer this above question ? Even I need answer for this.

qaEng1213 commented 5 years ago

@wakaleo any suggestions here ? Sometimes we have tests which rely on third party stuff and are unstable so having a mechanism for retrying failed tests would be great. Your answer would be helpful for other people, too.

elainMarley commented 5 years ago

Hi! I am interested in this too.

heer-abhishek commented 5 years ago

When we have very large cucumber tests and they run over long period of time , some of them fail due to timeout. But when we re run as single test they pass. Clients often ask for reason for failing tests and sometime we do not able to provide correct failing test.

We need the retry failing tests feature.

wakaleo commented 5 years ago

You can use the standard Cucumber retry feature for this

elainMarley commented 5 years ago

Hi! Could you please explain how must be configured standard Cucumber retry?

Thanks!

anoop5i commented 5 years ago

Hi! Could you please explain how must be configured standard Cucumber retry?

Thanks!

I use serenity cucumber with fail safe plugin there is a property for retry failed tests which is working fine in my case. -Dfailsafe.rerunFailingTestsCount={number of retries}

rdatla-fops commented 5 years ago

@anoopsivarajan Could you please tell me exact steps to achieve retry functionality in serenity cucumber, like changes in pom.xml and serenity.properties

wakaleo commented 5 years ago

There are a few approaches here: https://stackoverflow.com/questions/11719898/how-to-rerun-the-failed-scenarios-using-cucumber

rdatla-fops commented 5 years ago

@wakaleo above approach is for re-executing the failed test cases after whole test suite execution. Is there any way in serenity to retry failed test case the moment it fails in the test suite.

wakaleo commented 5 years ago

No

anoop5i commented 5 years ago

@rdatla-fops You need to use the maven-failsafe-plugin and add the failsafe property like below.

mvn clean verify -Dfailsafe.rerunFailingTestsCount=3.

The above command will run the test as normal, if it fails it will retry tests upto 3 times before failing the test. Read the cucumber section in the failsafe plugin documents.

https://maven.apache.org/surefire/maven-failsafe-plugin/examples/rerun-failing-tests.html

rdatla-fops commented 5 years ago

@anoopsivarajan I am using following file safe dependency maven-failsafe-plugin

2.18.1 and added -Dfailsafe.rerunFailingTestsCount=3 but no luck while explicitly closing the browser it is not trying to run again. Could you please help me out with any other changes in pom.xml or command line arguments or any other dependency need to be provided to use above feature
wakaleo commented 5 years ago

The maven-failsafe-plugin retry feature will work (to some extent) if you have separate test runners for each of your feature files.

anoop5i commented 5 years ago

@rdatla-fops You can find a sample Serenity starter screenplay cucumber project in this link(replace the driver with your version).

https://github.com/anoopsivarajan/Serenity-Retry-Test

If your run the test with mvn clean verify you will see the test failing and finishing the build.

Try with the command below and you will find that the test executes 4 times in total before failing the build.

mvn clean verify -Dfailsafe.rerunFailingTestsCount=3

jasonHolonis commented 5 years ago

I can confirm that -Dfailsafe.rerunFailingTestsCount=3 worked perfectly thanks for the info

Hi! Could you please explain how must be configured standard Cucumber retry? Thanks!

I use serenity cucumber with fail safe plugin there is a property for retry failed tests which is working fine in my case. -Dfailsafe.rerunFailingTestsCount={number of retries}

This worked for me.

william0096 commented 5 years ago

@anoopsivarajan I'm actually using the following command with maven "mvn verify -Dfailsafe.rerunFailingTestsCount=2", and it works properly, but I still have the issue with gradle, do you know how to solve it?, I checked your framework and it did not run with gradle