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));
}
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);
}
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();
}
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));
}
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));
}
Aggregations