How can I make only failed scenarios to be run again automatically on failure ?
Here is some clue on what I am doing:
- Pass TestRunner class from command line through cucumber-testng.xml file at run-time.
- 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 automatically re-run.
The "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
{
}
The "RunFailedTest" Class to re-run 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
{
}