0

I writing automation tests with Cucumber/Selenide and I want to rerun failed scenarios.

This is part of my project with only two small tests (one is failing) to demonstrate behavior: https://github.com/mtpx/cucumberRerun

I read how to do it on How to rerun the failed scenarios using Cucumber? and https://medium.com/@belek.bagishbekov/how-to-rerun-failed-test-cases-in-cucumber-b7fe9b1dcf9c

In my application.feature test runner(ApplicationTest) in @CucumberOptions's plugins section I have line: "rerun:rerun/failed_scenarios.txt", according to previous urls it should generate text file with failed scenario, but after test execution with 'mvn clean test' (with failed scenarios) - there's no any rerun.txt file.

Do You know what is wrong here? Why after build i dont have rerun.txt file? I using Selenide instead of Selenium, maybe problem is here?

moroyoung11
  • 63
  • 1
  • 9

2 Answers2

0

Create another scenario file as shown below. Let's say this as FailedScenarios.java. Whenever you notice any failed scenario run this file. This file will use target/rerun.txt as an input for running the scenarios.

This line is require:

features = "@target/rerun.txt",

Full CucumberOptions

@CucumberOptions(
    monochrome = true,
    features = "@target/rerun.txt", //Cucumber picks the failed scenarios from this file 
    format = {"pretty", "html:target/site/cucumber-pretty",
            "json:target/cucumber.json"}
  )
public class FailedScenarios {

}

You can use rerun file path other than target if you need to run failed Scenario also trigger from maven , In that case change the path in both file you main runner and failed test runner

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
  • I will check that later, but how can FailedScenarios.java access rerun.txt while previously failed scenarios not generate rerun.txt after failing test? – moroyoung11 Oct 04 '19 at 13:13
0

problem solved :) In pom i had line:

-Dcucumber.options="--plugin io.qameta.allure.cucumberjvm.AllureCucumberJvm"

This line overrides all plugins information in TestRunner

moroyoung11
  • 63
  • 1
  • 9