Skip to content

Instantly share code, notes, and snippets.

@ctataryn
Created February 6, 2012 16:04
Show Gist options
  • Save ctataryn/1752899 to your computer and use it in GitHub Desktop.
Save ctataryn/1752899 to your computer and use it in GitHub Desktop.
jBehave Transaction Problem
public class PlayerStoriesEmbedder extends Embedder {
private Configuration config;
private final CrossReference xref = new CrossReference();
//Tell JBehave what to do when running
@Override
public EmbedderControls embedderControls() {
return new EmbedderControls().doGenerateViewAfterStories(true).doIgnoreFailureInStories(false)
.doIgnoreFailureInView(true).doVerboseFailures(true).useThreads(1);//.useStoryTimeoutInSecs(60);
}
//configure JBehave
@Override
public Configuration configuration() {
if (config == null) {
Class<? extends PlayerStoriesEmbedder> 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));
config = new MostUsefulConfiguration()
.useStoryControls(
new StoryControls().doDryRun(false)
.doSkipScenariosAfterFailure(false))
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryParser(new RegexStoryParser(examplesTableFactory))
.useStoryPathResolver(new UnderscoredCamelCaseResolver())
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withCodeLocation(
CodeLocations
.codeLocationFromClass(embeddableClass))
.withDefaultFormats()
.withPathResolver(new ResolveToPackagedName())
.withViewResources(viewResources)
.withFormats(CONSOLE, TXT, HTML, XML)
.withFailureTrace(true)
.withFailureTraceCompression(true)
.withCrossReference(xref))
.useParameterConverters(parameterConverters)
// use '%' instead of '$' to identify parameters
// .useStepPatternParser(new
// RegexPrefixCapturingPatternParser("%"))
.useStepMonitor(xref.getStepMonitor());
}
return config;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment