Search in sources :

Example 1 with StoryControls

use of org.jbehave.core.embedder.StoryControls in project jbehave-core by jbehave.

the class ConfigurationProducer method getConfiguration.

@Produces
@WeldConfiguration
public Configuration getConfiguration() {
    LoadFromClasspath resourceLoader = new LoadFromClasspath(getClass().getClassLoader());
    TableTransformers tableTransformers = new TableTransformers();
    return new MostUsefulConfiguration().useStoryControls(new StoryControls().doDryRun(false).doSkipScenariosAfterFailure(false)).useStoryLoader(resourceLoader).useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML)).useParameterConverters(new ParameterConverters(resourceLoader, tableTransformers).addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")))).useTableTransformers(tableTransformers);
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) DateConverter(org.jbehave.core.steps.ParameterConverters.DateConverter) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) ParameterConverters(org.jbehave.core.steps.ParameterConverters) StoryControls(org.jbehave.core.embedder.StoryControls) SimpleDateFormat(java.text.SimpleDateFormat) TableTransformers(org.jbehave.core.model.TableTransformers) Produces(javax.enterprise.inject.Produces) WeldConfiguration(org.jbehave.core.annotations.weld.WeldConfiguration)

Example 2 with StoryControls

use of org.jbehave.core.embedder.StoryControls in project jbehave-core by jbehave.

the class CoreStory method configuration.

@Override
public Configuration configuration() {
    Class<? extends Embeddable> embeddableClass = this.getClass();
    Properties viewResources = new Properties();
    viewResources.put("decorateNonHtml", "true");
    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().useStoryControls(new StoryControls().doDryRun(false).doSkipScenariosAfterFailure(false)).useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryPathResolver(new UnderscoredCamelCaseResolver()).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withPathResolver(new ResolveToPackagedName()).withViewResources(viewResources).withFormats(CONSOLE, TXT, HTML_TEMPLATE, XML).withCrossReference(xref).withFailureTrace(true).withFailureTraceCompression(true)).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) ParameterControls(org.jbehave.core.steps.ParameterControls) DateConverter(org.jbehave.core.steps.ParameterConverters.DateConverter) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) ExamplesTableConverter(org.jbehave.core.steps.ParameterConverters.ExamplesTableConverter) StoryControls(org.jbehave.core.embedder.StoryControls) Properties(java.util.Properties) TableTransformers(org.jbehave.core.model.TableTransformers) UnderscoredCamelCaseResolver(org.jbehave.core.io.UnderscoredCamelCaseResolver) RegexStoryParser(org.jbehave.core.parsers.RegexStoryParser) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) ParameterConverters(org.jbehave.core.steps.ParameterConverters) ExamplesTableFactory(org.jbehave.core.model.ExamplesTableFactory) SimpleDateFormat(java.text.SimpleDateFormat) ResolveToPackagedName(org.jbehave.core.reporters.FilePrintStreamFactory.ResolveToPackagedName)

Example 3 with StoryControls

use of org.jbehave.core.embedder.StoryControls in project jbehave-core by jbehave.

the class ConfigurationProducer method getConfiguration.

@Produces
@WeldConfiguration
Configuration getConfiguration() {
    Properties viewResources = new Properties();
    viewResources.setProperty("index", "my-reports-index.ftl");
    viewResources.setProperty("decorateNonHtml", "true");
    TableTransformers tableTransformers = new TableTransformers();
    LoadFromURL resourceLoader = new LoadFromURL();
    return new MostUsefulConfiguration().useStoryControls(new StoryControls().doDryRun(true).doSkipScenariosAfterFailure(true)).useFailureStrategy(new SilentlyAbsorbingFailure()).useStoryLoader(resourceLoader).useStepPatternParser(new RegexPrefixCapturingPatternParser("MyPrefix")).useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML).withKeywords(new LocalizedKeywords(Locale.ITALIAN)).withRelativeDirectory("my-output-directory").withViewResources(viewResources).withFailureTrace(true)).useParameterConverters(new ParameterConverters(resourceLoader, tableTransformers).addConverters(new CustomConverter(), new MyDateConverter())).useTableTransformers(tableTransformers);
}
Also used : SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) RegexPrefixCapturingPatternParser(org.jbehave.core.parsers.RegexPrefixCapturingPatternParser) StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) LoadFromURL(org.jbehave.core.io.LoadFromURL) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) ParameterConverters(org.jbehave.core.steps.ParameterConverters) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) StoryControls(org.jbehave.core.embedder.StoryControls) Properties(java.util.Properties) TableTransformers(org.jbehave.core.model.TableTransformers) Produces(javax.enterprise.inject.Produces) WeldConfiguration(org.jbehave.core.annotations.weld.WeldConfiguration)

Aggregations

MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)3 StoryControls (org.jbehave.core.embedder.StoryControls)3 TableTransformers (org.jbehave.core.model.TableTransformers)3 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)3 ParameterConverters (org.jbehave.core.steps.ParameterConverters)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Properties (java.util.Properties)2 Produces (javax.enterprise.inject.Produces)2 WeldConfiguration (org.jbehave.core.annotations.weld.WeldConfiguration)2 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 DateConverter (org.jbehave.core.steps.ParameterConverters.DateConverter)2 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)1 LoadFromURL (org.jbehave.core.io.LoadFromURL)1 UnderscoredCamelCaseResolver (org.jbehave.core.io.UnderscoredCamelCaseResolver)1 ExamplesTableFactory (org.jbehave.core.model.ExamplesTableFactory)1 RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)1 RegexStoryParser (org.jbehave.core.parsers.RegexStoryParser)1 ResolveToPackagedName (org.jbehave.core.reporters.FilePrintStreamFactory.ResolveToPackagedName)1 ParameterControls (org.jbehave.core.steps.ParameterControls)1