JBehave BDD的起点是什么?

时间:2012-01-19 12:23:05

标签: jbehave

我已经通过JBehave官方文档,并开始制作样本项目。我很清楚 1.第一步:写一个故事 2.步骤2:将步骤映射到Java

我陷入了“配置故事”一步。有许多选项,如扩展JUnitStories,JUnitStory,Embedder等。 哪一个使用? 我怎样才能使一个简单的配置故事类工作。

.withFormats(CONSOLE,TXT,HTML,XML))已被弃用,那么在那个地方使用什么?
基本上,如果我直接使用提供的代码片段,它会产生编译错误。 有人可以帮忙吗

参考链接:http://jbehave.org/reference/stable/index.html

3 个答案:

答案 0 :(得分:1)

  1. JUnitStory:通过StoryPathResolver提供与文本故事的一对一映射。 JUnitStories:通过覆盖storyPaths()方法提供与显式指定的文本故事路径的多对一映射。对于您的情况,扩展JUnitStories就足够了。

  2. 对于格式,请使用如下:StoryReporterBuilder()。withDefaultFormats()。withFormats(Format.HTML,Format.CONSOLE);

答案 1 :(得分:0)

你需要下面的导入库

import static org.jbehave.core.reporters.Format.CONSOLE;

import static org.jbehave.core.reporters.Format.HTML_TEMPLATE;

import static org.jbehave.core.reporters.Format.TXT;

import static org.jbehave.core.reporters.Format.XML_TEMPLATE;

答案 2 :(得分:0)

我查看了源代码,似乎有两个同名的方法,一个(deprecated)声明为withFormats(Format... formats),另外一个 withFormats(org.jbehave.core.reporters.Format... formats)

因此,为了使用non-depricated版本,你应该这样写:

new StoryReporterBuilder()
    .withFormats( 
        org.jbehave.core.reporters.Format.CONSOLE,
        org.jbehave.core.reporters.Format.TXT,
        org.jbehave.core.reporters.Format.HTML,
        org.jbehave.core.reporters.Format.XML );