As a part of testing, i was using typescript language to develop the code which will be compatible for protractor, i was using BDD framework in which i had defined some cucumber options in my config.ts as following:
capabilities: {
specs: "../example.feature"
}
cucumberOpts: {
compiler: "ts:ts-node/register",
format: "rerun:./reports/rerun.txt",
require: "../../stepdefinations/*.ts",
strict: true
}
onComplete: () =>{
Reporter.createHTMLReport();
}
As mentioned in format, i was able to get the failed scenario line numbers in the rerun.txt which contains as following: example.feature:145:439
How to run this file before completing the test suite, how to rerun the failed scenarios for 3 times
Here is my simple and neat solution. Step 1: Write your cucumber java file as mentioned below with rerun:target/rerun. txt . Cucumber writes the failed scenarios line numbers in rerun.
First, you need to install Cucumber with npm install -g cucumber . Make sure it is installed in the same place as Protractor. Next, you'll have to install the protractor-cucumber-framework with npm install --save-dev protractor-cucumber-framework . This iteration is designed with Protractor 3.
As of November 2019, you can simply add retry: 3
(or however many retries you want to allow) to your cucumberOpts
.
There is one issue with this regarding the process still returning an exit code of 1 after retried failures succeed, I have opened issues with Protractor and protractor-cucumber-framework
trying to address this.
You can not currently rerun the failed tests in the same suite as your initial run. What it sounds like you want is retry functionality which there are actually pull requests up for
https://github.com/cucumber/cucumber-js/pull/1229
https://github.com/cucumber/cucumber-js/pull/1205/commits
What you need to do right now is rerun cucumber again against that txt file, to learn how to do that, check out https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#formats
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With