ClassLoader classLoader=getClass().getClassLoader();
ResourceLoader resourceLoader=new MultiLoader(classLoader);
RuntimeOptionsFactory roFactory=new RuntimeOptionsFactory(getClass());
RuntimeOptions ro=roFactory.create();
ro.getGlue().clear();
ro.getGlue().add("classpath:C:\\Users\\Cucumber\\src\\applications\\StepDefinitions\\");
ro.getFeaturePaths().clear();
String feature = "classpath:src/applications\\Features\\Feature1.Feature";
ro.getFeaturePaths().add(feature);
ro.getFilters().add("@Scenario1");
ClassFinder classFinder=new ResourceLoaderClassFinder(resourceLoader,classLoader);
cucumber.runtime.Runtime runtime=new cucumber.runtime.Runtime(resourceLoader,classFinder,classLoader,ro);
try {
runtime.run();
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
没有任何功能 [classpath:src / applications \ Features \ Feature1.Feature]匹配 过滤器:[@ Scenario1]
我确实提供了所有正确的输入,但无法运行该功能。
答案 0 :(得分:0)
ClassLoader classLoader=getClass().getClassLoader();
ResourceLoader resourceLoader=new MultiLoader(classLoader);
RuntimeOptionsFactory roFactory=new RuntimeOptionsFactory(getClass());
RuntimeOptions ro=roFactory.create();
ro.getGlue().clear();
ro.getGlue().add("applications.StepDefinitions");
ro.getFeaturePaths().clear();
String feature = "src/applications/Features";
ro.getFeaturePaths().add(feature);
ro.getFilters().add("@Scenario1");
ClassFinder classFinder=new ResourceLoaderClassFinder(resourceLoader,classLoader);
cucumber.runtime.Runtime runtime=new cucumber.runtime.Runtime(resourceLoader,classFinder,classLoader,ro);
try {
runtime.run();
}
catch (RuntimeException ex) {
throw new RuntimeException(ex);
}
and also updated the gherkin jar to 2.12.2 and this worked fine