Search in sources :

Example 1 with AnnotationBuilder

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

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

the class GuiceAnnotationBuilderBehaviour method shouldBuildEmptyStepsListIfAnnotationOrAnnotatedValuesNotPresent.

@Test
public void shouldBuildEmptyStepsListIfAnnotationOrAnnotatedValuesNotPresent() {
    AnnotationBuilder builderNotAnnotated = new GuiceAnnotationBuilder(NotAnnotated.class);
    assertThatStepsInstancesAre(builderNotAnnotated.buildCandidateSteps());
    AnnotationBuilder builderAnnotatedWithoutLocations = new GuiceAnnotationBuilder(AnnotatedWithoutModules.class);
    assertThatStepsInstancesAre(builderAnnotatedWithoutLocations.buildCandidateSteps());
}
Also used : AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) Test(org.junit.Test)

Example 3 with AnnotationBuilder

use of org.jbehave.core.configuration.AnnotationBuilder 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)

Example 4 with AnnotationBuilder

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

the class WeldAnnotationBuilderBehaviour method shouldCreateOnlyOneContainerForMultipleBuildInvocations.

@Test
public void shouldCreateOnlyOneContainerForMultipleBuildInvocations() {
    AnnotationBuilder builderAnnotated = createBuilder(AnnotatedUsingWeld.class);
    Configuration configuration = builderAnnotated.buildConfiguration();
    assertThat(builderAnnotated.buildConfiguration(), sameInstance(configuration));
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) Test(org.junit.Test)

Example 5 with AnnotationBuilder

use of org.jbehave.core.configuration.AnnotationBuilder 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

AnnotationBuilder (org.jbehave.core.configuration.AnnotationBuilder)26 Test (org.junit.Test)25 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)21 Configuration (org.jbehave.core.configuration.Configuration)18 SimpleDateFormat (java.text.SimpleDateFormat)6 Keywords (org.jbehave.core.configuration.Keywords)2 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)2 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)2 LoadFromURL (org.jbehave.core.io.LoadFromURL)2 RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)2 ParseException (java.text.ParseException)1 List (java.util.List)1 AnnotationMonitor (org.jbehave.core.configuration.AnnotationMonitor)1 WeldBootstrap (org.jbehave.core.configuration.weld.WeldBootstrap)1 CandidateSteps (org.jbehave.core.steps.CandidateSteps)1