2

Can anyone help me to rerun failed features in karate. below are the cucumber options and runner test which is using for parallel -

@CucumberOptions(features = "classpath:features/xxxxx/crud_api",
        format = {"pretty", "html:target/cucumber","json:target/cucumber/report.json", "rerun:target/rerun/rerun.txt" })



@Test
    public void  test() throws IOException {
        Results results = KarateRunnerTest.parallel(getClass(), threadCount, karateOutputPath);
        assertTrue("there are scenario failures", results.getFailCount() == 0);
    }
Mr. Venkat
  • 91
  • 1
  • 7

2 Answers2

2

Here is my reusable implementation using karate-1.0#retry-framework-experimental,

Results retryFailedTests(Results results) {
        System.out.println("======== Retrying failed tests ========");

        Results initialResults = results;
        List<ScenarioResult> retryResult = results.getScenarioResults().filter(ScenarioResult::isFailed)
                .parallel()
                .map(scenarioResult -> initialResults.getSuite().retryScenario(scenarioResult.getScenario()))
                .collect(Collectors.toList());
        for (ScenarioResult scenarioResult : retryResult) {
            results = results.getSuite().updateResults(scenarioResult);
        }
        return results;
    }

This java function takes care of retrying failed scenarios in parallel. You can check karate-timeline.html report to verify if the failed scenarios are retried in parallel.

Karthik P
  • 452
  • 5
  • 9
0

This is not something that Karate supports, but in dev mode (using the IDE for example) you can always re-run the failed tests manually.

You seem to be using annotation options not supported by Karate, e.g. format. Read the docs for what is supported it is limited to features and tags.

EDIT - Karate 1.0 has experimental support for this: https://github.com/intuit/karate/wiki/1.0-upgrade-guide#retry-framework-experimental

Peter Thomas
  • 47,282
  • 14
  • 68
  • 196
  • Hi @peter-thomas, is it possible to use this retry framework when using the standalone JAR? I imagine I have to implement a custom Runner somehow, but not seeing any examples of how to do that. – mariaines Nov 12 '21 at 21:09
  • 1
    @mariaines - ideally you should use the Java / Maven option, because you need to write code and compile it. but with the standalone JAR you can if you know what you are doing, refer: https://stackoverflow.com/a/56458094/143475 – Peter Thomas Nov 13 '21 at 02:33