How to rerun the failed scenarios using Cucumber?

Viewed 68161

I'm using Cucumber for my tests. How do I rerun only the failed tests?

5 Answers
task cucumber() {
    dependsOn assemble, compileTestJava
    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'json:target/cucumber-reports/json/cucumber.json',
                    '--plugin', "rerun:target/rerun.txt",
                    '--glue', 'steps',
                    'src/test/resources']
        }
    }
}

task cucumberRerunFailed() {
    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'json:target/cucumber-reports/json/cucumber.json',
                    '@target/rerun.txt']
        }
    }
}
Related