Search in sources :

Example 16 with Keywords

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

the class StoryReporterBuilderBehaviour method shouldBuildWithCustomKeywords.

@Test
public void shouldBuildWithCustomKeywords() throws IOException {
    // Given
    String storyPath = storyPath(MyStory.class);
    Keywords keywords = new LocalizedKeywords(new Locale("it"));
    final OutputStream out = new ByteArrayOutputStream();
    StoryReporterBuilder builder = new StoryReporterBuilder() {

        @Override
        protected FilePrintStreamFactory filePrintStreamFactory(String storyPath) {
            return new FilePrintStreamFactory(new StoryLocation(codeLocation(), storyPath)) {

                @Override
                public PrintStream createPrintStream() {
                    return new PrintStream(out);
                }
            };
        }
    };
    // When
    StoryReporter reporter = builder.withDefaultFormats().withFormats(TXT).withKeywords(keywords).build(storyPath);
    reporter.failed("Dato un passo che fallisce", new UUIDExceptionWrapper(new RuntimeException("ouch")));
    ((ConcurrentStoryReporter) reporter).invokeDelayed();
    // Then
    assertThat(builder.keywords(), equalTo(keywords));
    assertThat(out.toString(), equalTo("Dato un passo che fallisce (FALLITO)\n(java.lang.RuntimeException: ouch)\n"));
}
Also used : Locale(java.util.Locale) PrintStream(java.io.PrintStream) Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StoryLocation(org.jbehave.core.io.StoryLocation) UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper) Test(org.junit.Test)

Example 17 with Keywords

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

the class PerformableTree method parameterMeta.

private Meta parameterMeta(RunContext context, Map<String, String> parameters) {
    Meta meta = Meta.EMPTY;
    Keywords keywords = context.configuration().keywords();
    String metaText = keywords.meta();
    if (parameters.containsKey(metaText)) {
        meta = Meta.createMeta(parameters.get(metaText), keywords);
    }
    return meta;
}
Also used : Meta(org.jbehave.core.model.Meta) Keywords(org.jbehave.core.configuration.Keywords)

Example 18 with Keywords

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

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