Search in sources :

Example 6 with Keywords

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

the class GuiceAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotations.

@Test
public void shouldBuildConfigurationFromAnnotations() {
    AnnotationBuilder builder = new GuiceAnnotationBuilder(AnnotatedUsingGuice.class);
    Configuration configuration = builder.buildConfiguration();
    assertThat(configuration.storyControls().dryRun(), is(true));
    assertThat(configuration.storyControls().skipScenariosAfterFailure(), is(true));
    assertThat(configuration.failureStrategy(), instanceOf(SilentlyAbsorbingFailure.class));
    assertThat(configuration.storyLoader(), instanceOf(LoadFromURL.class));
    assertThat(configuration.stepPatternParser(), instanceOf(RegexPrefixCapturingPatternParser.class));
    assertThat(((RegexPrefixCapturingPatternParser) configuration.stepPatternParser()).getPrefix(), equalTo("MyPrefix"));
    assertThatCustomObjectIsConverted(configuration.parameterConverters());
    assertThatDateIsConvertedWithFormat(configuration.parameterConverters(), new SimpleDateFormat("yyyy-MM-dd"));
    assertThat(configuration.storyReporterBuilder().formats(), hasItems(CONSOLE, HTML, TXT, XML, STATS));
    Keywords keywords = configuration.storyReporterBuilder().keywords();
    assertThat(keywords, instanceOf(LocalizedKeywords.class));
    assertThat(((LocalizedKeywords) keywords).getLocale(), equalTo(Locale.ITALIAN));
    assertThat(configuration.storyReporterBuilder().outputDirectory().getName(), equalTo("my-output-directory"));
    assertThat(configuration.storyReporterBuilder().viewResources().getProperty("index"), equalTo("my-reports-index.ftl"));
    assertThat(configuration.storyReporterBuilder().viewResources().getProperty("decorateNonHtml"), equalTo("true"));
    assertThat(configuration.storyReporterBuilder().reportFailureTrace(), is(true));
}
Also used : SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) RegexPrefixCapturingPatternParser(org.jbehave.core.parsers.RegexPrefixCapturingPatternParser) LoadFromURL(org.jbehave.core.io.LoadFromURL) Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 7 with Keywords

use of org.jbehave.core.configuration.Keywords 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 8 with Keywords

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

the class StoryRunner method runScenariosParametrisedByExamples.

private void runScenariosParametrisedByExamples(RunContext context, Scenario scenario, Lifecycle lifecycle, Meta storyAndScenarioMeta) throws Throwable {
    ExamplesTable table = scenario.getExamplesTable();
    reporter.get().beforeExamples(scenario.getSteps(), table);
    Keywords keywords = context.configuration().keywords();
    for (Map<String, String> scenarioParameters : table.getRows()) {
        Meta parameterMeta = parameterMeta(keywords, scenarioParameters);
        if (!parameterMeta.isEmpty() && !context.filter.allow(parameterMeta)) {
            continue;
        }
        reporter.get().example(scenarioParameters);
        if (context.configuration().storyControls().resetStateBeforeScenario()) {
            context.resetState();
        }
        runBeforeOrAfterScenarioSteps(context, scenario, storyAndScenarioMeta, Stage.BEFORE, ScenarioType.EXAMPLE);
        runStepsWithLifecycle(context, lifecycle, scenarioParameters, scenario, storyAndScenarioMeta);
        runBeforeOrAfterScenarioSteps(context, scenario, storyAndScenarioMeta, Stage.AFTER, ScenarioType.EXAMPLE);
    }
    reporter.get().afterExamples();
}
Also used : Meta(org.jbehave.core.model.Meta) Keywords(org.jbehave.core.configuration.Keywords) ExamplesTable(org.jbehave.core.model.ExamplesTable)

Example 9 with Keywords

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

the class PicoAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotations.

@Test
public void shouldBuildConfigurationFromAnnotations() {
    PicoAnnotationBuilder builder = new PicoAnnotationBuilder(AnnotatedUsingPico.class);
    Configuration configuration = builder.buildConfiguration();
    assertThat(configuration.storyControls().dryRun(), is(true));
    assertThat(configuration.storyControls().skipScenariosAfterFailure(), is(true));
    assertThat(configuration.failureStrategy(), instanceOf(SilentlyAbsorbingFailure.class));
    assertThat(configuration.storyLoader(), instanceOf(LoadFromURL.class));
    assertThat(configuration.stepPatternParser(), instanceOf(RegexPrefixCapturingPatternParser.class));
    assertThat(((RegexPrefixCapturingPatternParser) configuration.stepPatternParser()).getPrefix(), equalTo("MyPrefix"));
    assertThatDateIsConvertedWithFormat(configuration.parameterConverters(), new SimpleDateFormat("yyyy-MM-dd"));
    assertThat(configuration.storyReporterBuilder().formats(), hasItems(CONSOLE, HTML, TXT, XML, STATS));
    Keywords keywords = configuration.storyReporterBuilder().keywords();
    assertThat(keywords, instanceOf(LocalizedKeywords.class));
    assertThat(((LocalizedKeywords) keywords).getLocale(), equalTo(Locale.ITALIAN));
    assertThat(configuration.storyReporterBuilder().outputDirectory().getName(), equalTo("my-output-directory"));
    assertThat(configuration.storyReporterBuilder().viewResources().getProperty("index"), equalTo("my-reports-index.ftl"));
    assertThat(configuration.storyReporterBuilder().viewResources().getProperty("decorateNonHtml"), equalTo("true"));
    assertThat(configuration.storyReporterBuilder().reportFailureTrace(), is(true));
}
Also used : SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) RegexPrefixCapturingPatternParser(org.jbehave.core.parsers.RegexPrefixCapturingPatternParser) LoadFromURL(org.jbehave.core.io.LoadFromURL) Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 10 with Keywords

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

the class WeldAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotations.

@Test
public void shouldBuildConfigurationFromAnnotations() {
    AnnotationBuilder builder = createBuilder(AnnotatedUsingWeld.class);
    Configuration configuration = builder.buildConfiguration();
    assertThat(configuration.storyControls().dryRun(), is(true));
    assertThat(configuration.storyControls().skipScenariosAfterFailure(), is(true));
    assertThat(configuration.failureStrategy(), instanceOf(SilentlyAbsorbingFailure.class));
    assertThat(configuration.storyLoader(), instanceOf(LoadFromURL.class));
    assertThat(configuration.stepPatternParser(), instanceOf(RegexPrefixCapturingPatternParser.class));
    assertThat(((RegexPrefixCapturingPatternParser) configuration.stepPatternParser()).getPrefix(), equalTo("MyPrefix"));
    assertThatCustomObjectIsConverted(configuration.parameterConverters());
    assertThatDateIsConvertedWithFormat(configuration.parameterConverters(), new SimpleDateFormat("yyyy-MM-dd"));
    assertThat(configuration.storyReporterBuilder().formats(), hasItems(CONSOLE, HTML, TXT, XML, STATS));
    Keywords keywords = configuration.storyReporterBuilder().keywords();
    assertThat(keywords, instanceOf(LocalizedKeywords.class));
    assertThat(((LocalizedKeywords) keywords).getLocale(), equalTo(Locale.ITALIAN));
    assertThat(configuration.storyReporterBuilder().outputDirectory().getName(), equalTo("my-output-directory"));
    assertThat(configuration.storyReporterBuilder().viewResources().getProperty("index"), equalTo("my-reports-index.ftl"));
    assertThat(configuration.storyReporterBuilder().viewResources().getProperty("decorateNonHtml"), equalTo("true"));
    assertThat(configuration.storyReporterBuilder().reportFailureTrace(), is(true));
}
Also used : SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) RegexPrefixCapturingPatternParser(org.jbehave.core.parsers.RegexPrefixCapturingPatternParser) LoadFromURL(org.jbehave.core.io.LoadFromURL) Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

Keywords (org.jbehave.core.configuration.Keywords)18 Test (org.junit.Test)12 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)9 Locale (java.util.Locale)4 Properties (java.util.Properties)4 Configuration (org.jbehave.core.configuration.Configuration)4 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)4 RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)4 SimpleDateFormat (java.text.SimpleDateFormat)3 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)3 LoadFromURL (org.jbehave.core.io.LoadFromURL)3 ParametrisedStep (org.jbehave.core.steps.StepCreator.ParametrisedStep)3 Matchers.anyString (org.mockito.Matchers.anyString)3 URL (java.net.URL)2 AnnotationBuilder (org.jbehave.core.configuration.AnnotationBuilder)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 Meta (org.jbehave.core.model.Meta)2 TableTransformers (org.jbehave.core.model.TableTransformers)2 RegexStoryParser (org.jbehave.core.parsers.RegexStoryParser)2 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)2