Search in sources :

Example 31 with LocalizedKeywords

use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.

the class StoryReporterBuilderBehaviour method shouldBuildWithReporterOfDifferentFormats.

private void shouldBuildWithReporterOfDifferentFormats(StoryReporterBuilder builder) {
    // Given
    String storyPath = storyPath(MyStory.class);
    Locale locale = Locale.getDefault();
    // When
    Format[] formats = { CONSOLE, IDE_CONSOLE, HTML, STATS, TXT, XML, JSON };
    StoryReporter reporter = builder.withDefaultFormats().withFormats(formats).withKeywords(new LocalizedKeywords(locale)).build(storyPath);
    // Then
    assertThat(builder.formats(), hasItems(CONSOLE, IDE_CONSOLE, HTML, STATS, TXT, XML, JSON));
    String[] upperCaseNames = new String[] { "CONSOLE", "IDE_CONSOLE", "HTML", "STATS", "TXT", "XML", "JSON" };
    assertThat(builder.formatNames(false), hasItems(upperCaseNames));
    String[] lowerCaseNames = new String[formats.length];
    for (int i = 0; i < upperCaseNames.length; i++) {
        lowerCaseNames[i] = upperCaseNames[i].toLowerCase(locale);
    }
    assertThat(builder.formatNames(true), hasItems(lowerCaseNames));
    assertThat(reporter, instanceOf(ConcurrentStoryReporter.class));
    StoryReporter delegate = ((ConcurrentStoryReporter) reporter).getDelegate();
    assertThat(delegate, instanceOf(DelegatingStoryReporter.class));
    Collection<StoryReporter> delegates = ((DelegatingStoryReporter) delegate).getDelegates();
    assertThat(delegates.size(), equalTo(formats.length));
}
Also used : Locale(java.util.Locale) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords)

Example 32 with LocalizedKeywords

use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.

the class SurefireReporterBehaviour method performableRoot.

private PerformableRoot performableRoot() {
    PerformableRoot root = new PerformableRoot();
    Story story = new Story("/path/to/story", new Description("An interesting story"), new Meta(Arrays.asList("+theme testing", "+author Mauro")), new Narrative("renovate my house", "customer", "get a loan"), new ArrayList<Scenario>());
    PerformableStory performableStory = new PerformableStory(story, new LocalizedKeywords(), false);
    root.add(performableStory);
    Scenario scenario = new Scenario(Arrays.asList(""));
    PerformableScenario performableScenario = new PerformableScenario(scenario, story.getPath());
    performableStory.add(performableScenario);
    List<StepMatch> stepMatches = new ArrayList<>();
    stepMatches.add(new StepMatch(new StepPattern(StepType.GIVEN, "(def)", "[abc]")));
    NormalPerformableScenario normalScenario = new NormalPerformableScenario(scenario);
    normalScenario.addSteps(new PerformableSteps(null, stepMatches));
    performableScenario.useNormalScenario(normalScenario);
    return root;
}
Also used : ArrayList(java.util.ArrayList) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) StepMatch(org.jbehave.core.embedder.MatchingStepMonitor.StepMatch)

Example 33 with LocalizedKeywords

use of org.jbehave.core.i18n.LocalizedKeywords 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 34 with LocalizedKeywords

use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.

the class SpringStoryReporterBuilderBehaviour method shouldAllowUseOfGettersAndSetters.

@Test
public void shouldAllowUseOfGettersAndSetters() {
    SpringStoryReporterBuilder builder = new SpringStoryReporterBuilder();
    URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
    builder.setCodeLocation(codeLocation);
    assertThat(builder.getCodeLocation(), equalTo(codeLocation));
    List<Format> formats = asList(Format.CONSOLE, Format.HTML);
    builder.setFormats(formats);
    assertThat(builder.getFormats(), equalTo(formats));
    Keywords keywords = new LocalizedKeywords();
    builder.setKeywords(keywords);
    assertThat(builder.getKeywords(), equalTo(keywords));
    String relativeDirectory = "reports";
    builder.setRelativeDirectory(relativeDirectory);
    assertThat(builder.getRelativeDirectory(), equalTo(relativeDirectory));
    assertThat(builder.getOutputDirectory(), endsWith(relativeDirectory));
    Properties viewResources = new Properties();
    builder.setViewResources(viewResources);
    assertThat(builder.getViewResources(), equalTo(viewResources));
    boolean reportFailureTrace = true;
    builder.setReportFailureTrace(reportFailureTrace);
    assertThat(builder.isReportFailureTrace(), equalTo(reportFailureTrace));
    FilePathResolver pathResolver = new FileConfiguration().getPathResolver();
    builder.setPathResolver(pathResolver);
    assertThat(builder.getPathResolver(), equalTo(pathResolver));
}
Also used : FileConfiguration(org.jbehave.core.reporters.FilePrintStreamFactory.FileConfiguration) FilePathResolver(org.jbehave.core.reporters.FilePrintStreamFactory.FilePathResolver) Format(org.jbehave.core.reporters.Format) Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) Properties(java.util.Properties) URL(java.net.URL) Test(org.junit.Test)

Example 35 with LocalizedKeywords

use of org.jbehave.core.i18n.LocalizedKeywords 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

LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)35 Test (org.junit.Test)23 Properties (java.util.Properties)14 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)10 Locale (java.util.Locale)8 Keywords (org.jbehave.core.configuration.Keywords)8 SimpleDateFormat (java.text.SimpleDateFormat)7 UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)7 TableTransformers (org.jbehave.core.model.TableTransformers)7 Configuration (org.jbehave.core.configuration.Configuration)6 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)6 RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)6 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)5 LoadFromURL (org.jbehave.core.io.LoadFromURL)5 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)5 ParameterConverters (org.jbehave.core.steps.ParameterConverters)5 RegexStoryParser (org.jbehave.core.parsers.RegexStoryParser)4 ArrayList (java.util.ArrayList)3 StoryLocation (org.jbehave.core.io.StoryLocation)3 ExamplesTableFactory (org.jbehave.core.model.ExamplesTableFactory)3