Search in sources :

Example 6 with RegexPrefixCapturingPatternParser

use of org.jbehave.core.parsers.RegexPrefixCapturingPatternParser in project jbehave-core by jbehave.

the class StepCandidateBehaviour method candidateWith.

private StepCandidate candidateWith(String patternAsString, StepType stepType, Method method, Object instance, ParameterControls parameterControls) {
    Class<?> stepsType = instance.getClass();
    MostUsefulConfiguration configuration = new MostUsefulConfiguration();
    InjectableStepsFactory stepsFactory = new InstanceStepsFactory(configuration, instance);
    return new StepCandidate(patternAsString, 0, stepType, method, stepsType, stepsFactory, new StepsContext(), keywords, new RegexPrefixCapturingPatternParser(), configuration.parameterConverters(), parameterControls);
}
Also used : StepsContext(org.jbehave.core.steps.context.StepsContext) RegexPrefixCapturingPatternParser(org.jbehave.core.parsers.RegexPrefixCapturingPatternParser) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration)

Example 7 with RegexPrefixCapturingPatternParser

use of org.jbehave.core.parsers.RegexPrefixCapturingPatternParser in project jbehave-core by jbehave.

the class SpringAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotations.

@Test
public void shouldBuildConfigurationFromAnnotations() {
    SpringAnnotationBuilder builder = new SpringAnnotationBuilder(AnnotatedUsingSpring.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.parameterControls().nameDelimiterLeft(), equalTo("["));
    assertThat(configuration.parameterControls().nameDelimiterRight(), equalTo("]"));
    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) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 8 with RegexPrefixCapturingPatternParser

use of org.jbehave.core.parsers.RegexPrefixCapturingPatternParser 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

RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)8 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)6 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)6 SimpleDateFormat (java.text.SimpleDateFormat)5 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)5 LoadFromURL (org.jbehave.core.io.LoadFromURL)5 Test (org.junit.Test)5 Keywords (org.jbehave.core.configuration.Keywords)4 Configuration (org.jbehave.core.configuration.Configuration)3 TableTransformers (org.jbehave.core.model.TableTransformers)3 AnnotationBuilder (org.jbehave.core.configuration.AnnotationBuilder)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)2 ParameterConverters (org.jbehave.core.steps.ParameterConverters)2 StepsContext (org.jbehave.core.steps.context.StepsContext)2 Method (java.lang.reflect.Method)1 Properties (java.util.Properties)1 Produces (javax.enterprise.inject.Produces)1 WeldConfiguration (org.jbehave.core.annotations.weld.WeldConfiguration)1 StartingWordNotFound (org.jbehave.core.configuration.Keywords.StartingWordNotFound)1