use of org.jbehave.core.steps.ParameterControls in project jbehave-core by jbehave.
the class CoreStories method configuration.
@Override
public Configuration configuration() {
// alternative use #useConfiguration() in the constructor
if (super.hasConfiguration()) {
return super.configuration();
}
Class<? extends Embeddable> embeddableClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
viewResources.put("reports", "ftl/jbehave-reports.ftl");
LoadFromClasspath resourceLoader = new LoadFromClasspath(embeddableClass);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, tableTransformers);
// factory to allow parameter conversion and loading from external
// resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), resourceLoader, parameterConverters, parameterControls, tableTransformers);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")), new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration().useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withViewResources(viewResources).withFormats(contextFormat, CONSOLE, TXT, HTML_TEMPLATE, XML_TEMPLATE).withFailureTrace(true).withFailureTraceCompression(true).withCrossReference(xref).withSurefireReporter(new SurefireReporter(embeddableClass))).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.steps.ParameterControls in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldParseTableWithDifferentCustomSeparators.
@Test
public void shouldParseTableWithDifferentCustomSeparators() {
String headerSeparator = "!!";
String valueSeparator = "!";
String tableWithCustomSeparator = wikiTableAsString.replace("|", "!");
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath(), parameterControls, tableTransformers, true);
ExamplesTable table = new ExamplesTable(tableWithCustomSeparator, headerSeparator, valueSeparator, parameterConverters, parameterControls, tableTransformers);
assertThat(table.getHeaderSeparator(), equalTo(headerSeparator));
assertThat(table.getValueSeparator(), equalTo(valueSeparator));
ensureColumnOrderIsPreserved(table);
assertThat(table.asString(), equalTo("!!one!!two!!\n!11!12!\n!21!22!\n"));
}
use of org.jbehave.core.steps.ParameterControls in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method createFactory.
private ExamplesTableFactory createFactory(ParameterConverter... converters) {
LoadFromClasspath resourceLoader = new LoadFromClasspath();
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, parameterControls, tableTransformers, true);
parameterConverters.addConverters(converters);
return new ExamplesTableFactory(resourceLoader, parameterConverters, parameterControls, tableTransformers);
}
use of org.jbehave.core.steps.ParameterControls in project jbehave-core by jbehave.
the class LocalizedStories method configuration.
@Override
public Configuration configuration() {
ClassLoader classLoader = this.getClass().getClassLoader();
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
Keywords keywords = new LocalizedKeywords(locale());
Properties properties = new Properties();
properties.setProperty("reports", "ftl/jbehave-reports.ftl");
properties.setProperty("encoding", "UTF-8");
LoadFromClasspath resourceLoader = new LoadFromClasspath(classLoader);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, parameterControls, tableTransformers, true).addConverters(customConverters(keywords, resourceLoader, tableTransformers));
return new MostUsefulConfiguration().useKeywords(keywords).useStepCollector(new MarkUnmatchedStepsAsPending(keywords)).useStoryParser(new RegexStoryParser(keywords, resourceLoader, tableTransformers)).useStoryLoader(resourceLoader).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(codeLocation).withPathResolver(new ResolveToSimpleName()).withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML).withFailureTrace(false).withViewResources(properties).withKeywords(keywords)).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.steps.ParameterControls in project jbehave-core by jbehave.
the class MyStories method configuration.
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
LoadFromClasspath resourceLoader = new LoadFromClasspath(embeddableClass);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, tableTransformers);
// factory to allow parameter conversion and loading from external resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), resourceLoader, parameterConverters, parameterControls, tableTransformers);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")), new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration().useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML)).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
Aggregations