使用不同的测试运行器(基于注释的测试运行器),拾取并运行步骤。基于注释的方法似乎并不支持步骤工厂,因此我交换了模型。现在,它将加载步骤类(调用构造函数时会发生一些可见的事情),但它不会识别其中的任何步骤。有任何想法吗?这是我的嵌入式课程:
公共类LoginAcceptanceFull扩展了JUnitStories {
private final CrossReference xref = new CrossReference();
public LoginAcceptanceFull() {
configuredEmbedder().embedderControls().doGenerateViewAfterStories(true)
.doIgnoreFailureInStories(true).doIgnoreFailureInView(true).useThreads(2)
.useStoryTimeoutInSecs(60);
}
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters();
// factory to allow parameter conversion and loading from external
// resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(),
new LoadFromClasspath(embeddableClass), parameterConverters);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")),
new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration()
.useStoryControls(new StoryControls().doDryRun(false).doSkipScenariosAfterFailure(false))
.useStoryLoader(new LoadFromURL())
.useStoryParser(new RegexStoryParser(examplesTableFactory))
.useStoryPathResolver(new UnderscoredCamelCaseResolver())
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
.withDefaultFormats().withPathResolver(new ResolveToPackagedName())
.withViewResources(viewResources).withFormats(org.jbehave.core.reporters.Format.HTML,
org.jbehave.core.reporters.Format.TXT, org.jbehave.core.reporters.Format.XML)
.withFailureTrace(true).withFailureTraceCompression(true).withCrossReference(xref))
.useParameterConverters(parameterConverters)
.useStepPatternParser(new RegexPrefixCapturingPatternParser("%"))
.useStepMonitor(xref.getStepMonitor());
}
@Override
public InjectableStepsFactory stepsFactory(){
return new InstanceStepsFactory(configuration(), new LoginSteps());
}
@Override
protected List<String> storyPaths(){
String codeLocation = org.jbehave.core.io.CodeLocations.codeLocationFromClass(this.getClass()).getFile();
return new StoryFinder().findPaths(codeLocation, asList("**/login_trial.story"),
asList(""), "file:" + codeLocation);
}
}
答案 0 :(得分:1)
我找到了。就在这里是罪魁祸首:
.useStepPatternParser(new RegexPrefixCapturingPatternParser("%"))
这导致JBehave无法识别@Given注释,因此JBehave假设所有内容都需要一个步骤,并将它们全部列为待处理(或者因为缺少@Given步骤而跳过它们)。一旦我拉出配置的那部分,一切都很酷。