问题
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
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/58096754/how-to-rerun-the-failed-cucumber-scenarios-in-protractor