JBehave - 所有步骤都标记为待处理?
我正在尝试创建并运行一个简单的 JUnitStory 来运行 .story 文件。
我有这样的:
class Scenario1 extends JUnitStory {
@Delegate MySteps steps = new MySteps()
@Override
public Configuration configuration() {
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromRelativeFile(new File('src/test/groovy').toURL()))
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withDefaultFormats()
.withFormats(Format.HTML, Format.CONSOLE, Format.TXT)
);
}
@Override
public List candidateSteps() {
final candidateSteps = new InstanceStepsFactory(configuration(), this).createCandidateSteps()
return candidateSteps;
}
}
无论有没有委托(复制并粘贴 MySteps 的所有带注释的方法),每当我运行 JBehave 时,我都会得到以下输出:
somePattern(){
// PENDING
}
就像各个故事没有选择步骤一样。
当我创建“Stories”类并使用 storyPaths
拉取所有故事文件时,会定义各个步骤。使用调试器,我看到candidateSteps 被命中,但它没有提取所需的数据。
这里可能发生了什么?
I'm trying to create and run a simple JUnitStory to run a .story file.
I have this:
class Scenario1 extends JUnitStory {
@Delegate MySteps steps = new MySteps()
@Override
public Configuration configuration() {
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromRelativeFile(new File('src/test/groovy').toURL()))
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withDefaultFormats()
.withFormats(Format.HTML, Format.CONSOLE, Format.TXT)
);
}
@Override
public List candidateSteps() {
final candidateSteps = new InstanceStepsFactory(configuration(), this).createCandidateSteps()
return candidateSteps;
}
}
With or without the delegate (copying and pasting in all the annotated methods of MySteps), whenever I run JBehave, I get the following output:
somePattern(){
// PENDING
}
It's like the individual stories don't pick up the steps.
When I create a "Stories" class and pull all the story files in with storyPaths
, the individual steps are defined. Using a debugger, I see that candidateSteps is being hit, but it's not pulling in the data it needs to.
What could possibly be going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您无需委派步骤。而且你不应该覆盖candidateSteps,而应该覆盖stepsFactory。在 JBehave 的更高版本中,candidateSteps 已被弃用,以使对工厂方法的偏好更加突出(http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/ConfigurableEmbedder.html#candidateSteps() )
请参阅此博客,其中我解释了基本的JBehave 配置工作更详细:
http://blog.codecentric.de/en/2012/06/jbehave-configuration-tutorial/
安德烈亚斯
You don't need to delegate to the Steps. And also you should not override candidateSteps, but rather stepsFactory. In later versions of JBehave, candidateSteps is deprecated, to make that preference for the factory method more prominent ( http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/ConfigurableEmbedder.html#candidateSteps() )
See this blog, where I explained how the basic JBehave configuration works in more detail:
http://blog.codecentric.de/en/2012/06/jbehave-configuration-tutorial/
Andreas
朋友你的答案是这样的:
包的格式已更改。
这是已弃用的
导入静态 org.jbehave.core.reporters.StoryReporterBuilder.Format.HTML;
这是新的:)
导入静态 org.jbehave.core.reporters.Format.HTML;
花了一段时间才找到答案,但隐藏在 jbehave 文档中
希望它有帮助!
干杯!
Here is your answer buddy:
The package of format has Changed.
This is the deprecated
import static org.jbehave.core.reporters.StoryReporterBuilder.Format.HTML;
This is the new one :)
import static org.jbehave.core.reporters.Format.HTML;
Took a while to find the answer, but was hidden on the jbehave documentation
Hope it helps!
Cheers!
您不需要使用 @Delegate - 您的 JUnitStory 不是您的 Steps 类。你能尝试在有这个的地方传递步骤吗?
当您传入已为 Steps 类进行字节码操作的类时,JBehave 可能不再看到 jbehave 注释。
You shouldn't need to use the @Delegate - your JUnitStory is not your Steps class. Can you try passing in steps where you have this?
When you pass in a class that has been bytecode manipulated for Steps classes, JBehave may not see the jbehave annotations anymore.
JBehave 是一种古老的、不发达的技术。不要使用它。
JBehave is old, underdeveloped technology. Don't use it.