运行Cucumber Runtime时出错,因为[classpath:src / A \ B \ Feature1.Feature]中的所有功能都没有匹配过滤器:[@ Scenario1]

时间:2016-05-19 09:35:02

标签: java

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]

我确实提供了所有正确的输入,但无法运行该功能。

1 个答案:

答案 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