I need to execute one scenario which is part of one feature 100 times. There is no scenario outline as there is no data parameterization. I just need to perform gorilla testing on this particular scenario so as to make sure it passes every single time without any fail. Some of my team members observed failure a couple of times, so need to validate the stability.
Runner class code:
public class Baserunner extends AbstractTestNGCucumberTests{
private TestNGCucumberRunner testNGCucumberRunner;
@BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
System.out.println("Test");
String browsername = "IExplorer";
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
BaseConfig.ConfigFileReader();
BaseConfig.launchbrowser(browsername);
// BaseConfig.executeScript();
}
@Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "features")
public void feature(CucumberFeatureWrapper cucumberFeature) {
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}
@DataProvider
public Object[][] features() {
return testNGCucumberRunner.provideFeatures();
}
@AfterClass(alwaysRun = true)
public void tearDownClass() throws Exception {
testNGCucumberRunner.finish();
BaseConfig.closeBrowser();
}
You could try this below hack with a looping logic in the runner class.
@Override
@Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "features")
public void feature(CucumberFeatureWrapper cucumberFeature) {
for(int i=0;i<100;i++)
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}
Plus you have to make sure only one scenario is executed by specifying the line number.
@CucumberOptions(features = {"src/test/resources/stepdef/scenarios.feature:3"})
What version of cucumber are you using?