mercredi 7 février 2018

Please suggest ways how to re-run only failed scenario automatically in cucumber java+testng?

Here is some clue I am doing: Passing TestRunner class from command line through cucumber-testng.xml file at run-time and I am able to see rerun.txt file after scenario failed with feature/GM/TK/payment.feature:71(pointing to failed scenario) but failed scenario is not running automatically.

Created one TestRunner java file---

@RunWith(Cucumber.class)
@CucumberOptions(strict = true, 
features = { "src/test/resources/" }, //feature file location
glue = { "com/test/stepdefs", "com.test.cucumber.hooks" },   //hooks and stepdef location
plugin = { "json:target/cucumber-report-composite.json", "pretty",
        "rerun:target/rerun.txt"})
public class CucumberTestRunner extends AbstractTestNGCucumberTests {

}
Created another file RunFailedTest Class to rerun from rerun.txt file

@RunWith(Cucumber.class)
@CucumberOptions(strict = false, 
features = { "@target/rerun.txt"  },   //rerun location
glue = { "com/test/stepdefs", "com.test.cucumber.hooks" }, //hooks and stepdef location
plugin = {"pretty", "html:target/site/cucumber-pretty",
"json:target/cucumber.json"})
class RunFailedTest {
}

Aucun commentaire:

Enregistrer un commentaire