I want to run the tags by calling the Cucumber class which is as below. How this can be achieved?
我想通过调用Cucumber类来运行标记,如下所示。如何才能做到这一点?
public class SuiteRunner extends AbstractTestNGCucumberTests {
private TestNGCucumberRunner testNGCucumberRunner;
@BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
}
@Test(dataProvider = "features")
public void feature(PickleEventWrapper eventwrapper, CucumberFeatureWrapper cucumberFeature) throws Throwable {
testNGCucumberRunner.runScenario(eventwrapper.getPickleEvent());
}
@DataProvider
public Object[][] features() {
return testNGCucumberRunner.provideScenarios();
}
@AfterClass(alwaysRun = true)
public void tearDownClass() throws Exception {
testNGCucumberRunner.finish();
}
}
Tried to achieve this using the below code. But it giving me compilation error for CustomClass loader.
尝试使用下面的代码来实现这一点。但是它给了我CustomClass加载器的编译错误。
ClassLoader classLoader = CustomClass.class.getClassLoader();
ResourceLoader resourceLoader = new MultiLoader(classLoader);
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
/* Adding cucumber plugins */
List<String> pluginList = new ArrayList<String>();
pluginList.add("--plugin");
pluginList.add("html:target/cucumber-html-report");
pluginList.add("--plugin");
pluginList.add("json:target/cucumber.json");
pluginList.add("--plugin");
pluginList.add("com.cucumber.listener.ExtentCucumberFormatter:");
pluginList.add("--plugin");
pluginList.add("rerun:target/failedScenarios.txt");
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!