Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rerun the failed cucumber scenarios in protractor?

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

like image 749
Suri Suraj Avatar asked Sep 25 '19 10:09

Suri Suraj


People also ask

How do you rerun in Cucumber failed scenarios?

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.

How do you use a Cucumber with a protractor?

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.


2 Answers

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.

like image 56
Anthony Chuinard Avatar answered Nov 27 '22 09:11

Anthony Chuinard


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

like image 22
Ray Avatar answered Nov 27 '22 08:11

Ray