Search in sources :

Example 21 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class ReportTransformBehaviour method runStories.

private void runStories(String... storyPaths) {
    StoryReporterBuilder storyReporterBuilder = new StoryReporterBuilder().withDefaultFormats().withCodeLocation(CodeLocations.codeLocationFromClass(ReportTransformBehaviour.class)).withFormats(Format.XML);
    Configuration configuration = new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass())).useStoryReporterBuilder(storyReporterBuilder).useFailureStrategy(new SilentlyAbsorbingFailure()).useStepCollector(new MarkUnmatchedStepsAsPending(new StepFinder(new ByLevenshteinDistance())));
    Embedder embedder = new Embedder();
    embedder.useEmbedderControls(new EmbedderControls().doGenerateViewAfterStories(false));
    embedder.useConfiguration(configuration);
    embedder.useCandidateSteps(new InstanceStepsFactory(configuration, new MySteps()).createCandidateSteps());
    embedder.useMetaFilters(asList("-skip true"));
    try {
        embedder.runStoriesAsPaths(asList(storyPaths));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) StepFinder(org.jbehave.core.steps.StepFinder) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Embedder(org.jbehave.core.embedder.Embedder) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) ByLevenshteinDistance(org.jbehave.core.steps.StepFinder.ByLevenshteinDistance) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) InstanceStepsFactory(org.jbehave.core.steps.InstanceStepsFactory) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) MarkUnmatchedStepsAsPending(org.jbehave.core.steps.MarkUnmatchedStepsAsPending)

Example 22 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration 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);
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) ParameterControls(org.jbehave.core.steps.ParameterControls) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) Properties(java.util.Properties) URL(java.net.URL) TableTransformers(org.jbehave.core.model.TableTransformers) RegexStoryParser(org.jbehave.core.parsers.RegexStoryParser) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) ParameterConverters(org.jbehave.core.steps.ParameterConverters) MarkUnmatchedStepsAsPending(org.jbehave.core.steps.MarkUnmatchedStepsAsPending) ResolveToSimpleName(org.jbehave.core.reporters.FilePrintStreamFactory.ResolveToSimpleName)

Example 23 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class CoreStoryMaps method configuration.

@Override
public Configuration configuration() {
    TableTransformers tableTransformers = new TableTransformers();
    ExamplesTableFactory tableFactory = new ExamplesTableFactory(new LoadFromClasspath(this.getClass()), tableTransformers);
    return new MostUsefulConfiguration().useStoryParser(new RegexStoryParser(tableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass()))).useTableTransformers(tableTransformers);
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) RegexStoryParser(org.jbehave.core.parsers.RegexStoryParser) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) ExamplesTableFactory(org.jbehave.core.model.ExamplesTableFactory) TableTransformers(org.jbehave.core.model.TableTransformers)

Example 24 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration 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);
}
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) TableTransformers(org.jbehave.core.model.TableTransformers) 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)

Example 25 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class WeldAnnotationBuilderBehaviour method shouldBuildDefaultConfigurationIfAnnotationNotPresent.

@Test
public void shouldBuildDefaultConfigurationIfAnnotationNotPresent() {
    AnnotationBuilder builderNotAnnotated = createBuilder(NotAnnotated.class);
    assertThatConfigurationIs(builderNotAnnotated.buildConfiguration(), new MostUsefulConfiguration());
}
Also used : AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Aggregations

MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)66 Test (org.junit.Test)52 Configuration (org.jbehave.core.configuration.Configuration)14 CandidateSteps (org.jbehave.core.steps.CandidateSteps)14 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)11 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)8 TableTransformers (org.jbehave.core.model.TableTransformers)8 Method (java.lang.reflect.Method)7 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)7 ParameterConverters (org.jbehave.core.steps.ParameterConverters)7 SimpleDateFormat (java.text.SimpleDateFormat)5 HashMap (java.util.HashMap)5 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)5 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)5 BeforeOrAfterFailed (org.jbehave.core.failures.BeforeOrAfterFailed)5 Failed (org.jbehave.core.steps.AbstractStepResult.Failed)5 ApplicationContext (org.springframework.context.ApplicationContext)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputStream (java.io.OutputStream)4 PrintStream (java.io.PrintStream)4