Skip to content

Instantly share code, notes, and snippets.

@shankybnl
Last active June 13, 2018 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankybnl/074c66655cf75fa54dcde07bfccb6925 to your computer and use it in GitHub Desktop.
Save shankybnl/074c66655cf75fa54dcde07bfccb6925 to your computer and use it in GitHub Desktop.
CucumberRunnerUtil.java
@RunWith(Cucumber.class)
@CucumberOptions(
monochrome = true,
features = "src/test/java/features",
glue = {"utils","steps"},
tags = {"@single"},
format = {
"pretty",
"html:target/cucumber-reports/cucumber-pretty",
"json:target/cucumber-reports/CucumberTestReport.json",
"rerun:target/cucumber-reports/rerun.txt"}
)
public class CucumberRunnerUtil {
private TestNGCucumberRunner testNGCucumberRunner;
@BeforeSuite
@org.testng.annotations.Parameters("environment")
public void setUpEnvironment(String environment){
CommonUtil.environmentSetUp(environment);
CommonUtil.initialSetUp();
}
@BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
}
@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();
}
@AfterSuite
public void cleanUp(){
CrudOperations.closeSessionFactory();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment