Search in sources :

Example 6 with ViewGenerator

use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldNotGenerateViewIfSkipFlagIsSet.

@Test
public void shouldNotGenerateViewIfSkipFlagIsSet() throws Throwable {
    // Given
    PerformableTree performableTree = mock(PerformableTree.class);
    EmbedderControls embedderControls = new EmbedderControls().doSkip(true);
    OutputStream out = new ByteArrayOutputStream();
    EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
    ViewGenerator viewGenerator = mock(ViewGenerator.class);
    Embedder embedder = embedderWith(performableTree, embedderControls, monitor);
    embedder.configuration().useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats());
    embedder.configuration().useViewGenerator(viewGenerator);
    File outputDirectory = new File("target/output");
    List<String> formats = asList("html");
    Properties viewResources = new Properties();
    embedder.generateReportsView(outputDirectory, formats, viewResources);
    // Then
    verify(viewGenerator, never()).generateReportsView(outputDirectory, formats, viewResources);
    assertThat(out.toString(), not(containsString("Generating stories view")));
    assertThat(out.toString(), not(containsString("Stories view generated")));
}
Also used : PrintStream(java.io.PrintStream) StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) ViewGenerator(org.jbehave.core.reporters.ViewGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 7 with ViewGenerator

use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldThrowExceptionIfNoScenariosRunForStoriesAndIgnoreFlagIsNotSet.

@Test(expected = RunningStoriesFailed.class)
public void shouldThrowExceptionIfNoScenariosRunForStoriesAndIgnoreFlagIsNotSet() throws Throwable {
    // Given
    PerformableTree performableTree = mock(PerformableTree.class);
    EmbedderControls embedderControls = new EmbedderControls();
    OutputStream out = new ByteArrayOutputStream();
    EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
    ViewGenerator viewGenerator = mock(ViewGenerator.class);
    Embedder embedder = embedderWith(performableTree, embedderControls, monitor);
    embedder.configuration().useViewGenerator(viewGenerator);
    File outputDirectory = new File("target/output");
    List<String> formats = asList("html");
    Properties viewResources = new Properties();
    when(viewGenerator.getReportsCount()).thenReturn(new ReportsCount(1, 0, 0, 0, 0, 0, 0, 1));
    embedder.generateReportsView(outputDirectory, formats, viewResources);
// Then fail as expected
}
Also used : PrintStream(java.io.PrintStream) ViewGenerator(org.jbehave.core.reporters.ViewGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) Properties(java.util.Properties) ReportsCount(org.jbehave.core.reporters.ReportsCount) File(java.io.File) Test(org.junit.Test)

Example 8 with ViewGenerator

use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldThrowExceptionIfScenariosFailedAndIgnoreFlagIsNotSet.

@Test(expected = RunningStoriesFailed.class)
public void shouldThrowExceptionIfScenariosFailedAndIgnoreFlagIsNotSet() throws Throwable {
    // Given
    PerformableTree performableTree = mock(PerformableTree.class);
    EmbedderControls embedderControls = new EmbedderControls();
    OutputStream out = new ByteArrayOutputStream();
    EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
    ViewGenerator viewGenerator = mock(ViewGenerator.class);
    Embedder embedder = embedderWith(performableTree, embedderControls, monitor);
    embedder.configuration().useViewGenerator(viewGenerator);
    File outputDirectory = new File("target/output");
    List<String> formats = asList("html");
    Properties viewResources = new Properties();
    when(viewGenerator.getReportsCount()).thenReturn(new ReportsCount(1, 0, 1, 2, 1, 1, 1, 1));
    embedder.generateReportsView(outputDirectory, formats, viewResources);
// Then fail as expected
}
Also used : PrintStream(java.io.PrintStream) ViewGenerator(org.jbehave.core.reporters.ViewGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) Properties(java.util.Properties) ReportsCount(org.jbehave.core.reporters.ReportsCount) File(java.io.File) Test(org.junit.Test)

Example 9 with ViewGenerator

use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldNotThrowExceptionIfScenariosFailedAndIgnoreFlagIsSet.

@Test
public void shouldNotThrowExceptionIfScenariosFailedAndIgnoreFlagIsSet() throws Throwable {
    // Given
    PerformableTree performableTree = mock(PerformableTree.class);
    EmbedderControls embedderControls = new EmbedderControls().doIgnoreFailureInView(true);
    OutputStream out = new ByteArrayOutputStream();
    EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
    ViewGenerator viewGenerator = mock(ViewGenerator.class);
    Embedder embedder = embedderWith(performableTree, embedderControls, monitor);
    embedder.configuration().useViewGenerator(viewGenerator);
    File outputDirectory = new File("target/output");
    List<String> formats = asList("html");
    Properties viewResources = new Properties();
    when(viewGenerator.getReportsCount()).thenReturn(new ReportsCount(1, 0, 1, 2, 1, 0, 1, 1));
    embedder.generateReportsView(outputDirectory, formats, viewResources);
    // Then
    verify(viewGenerator).generateReportsView(outputDirectory, formats, viewResources);
    assertThatReportsViewGenerated(out);
}
Also used : PrintStream(java.io.PrintStream) ViewGenerator(org.jbehave.core.reporters.ViewGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) Properties(java.util.Properties) ReportsCount(org.jbehave.core.reporters.ReportsCount) File(java.io.File) Test(org.junit.Test)

Example 10 with ViewGenerator

use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldFailWhenGeneratingReportsViewWithFailedSteps.

@Test(expected = RunningStoriesFailed.class)
public void shouldFailWhenGeneratingReportsViewWithFailedSteps() throws Throwable {
    // Given
    PerformableTree performableTree = mock(PerformableTree.class);
    EmbedderControls embedderControls = new EmbedderControls().doGenerateViewAfterStories(false);
    OutputStream out = new ByteArrayOutputStream();
    EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
    ViewGenerator viewGenerator = mock(ViewGenerator.class);
    Embedder embedder = embedderWith(performableTree, embedderControls, monitor);
    embedder.configuration().useViewGenerator(viewGenerator);
    File outputDirectory = new File("target/output");
    List<String> formats = asList("html");
    Properties viewResources = new Properties();
    when(viewGenerator.getReportsCount()).thenReturn(new ReportsCount(2, 0, 0, 2, 1, 0, 0, 1));
    embedder.generateReportsView(outputDirectory, formats, viewResources);
    // Then
    verify(viewGenerator).generateReportsView(outputDirectory, formats, viewResources);
    assertThatReportsViewGenerated(out);
}
Also used : PrintStream(java.io.PrintStream) ViewGenerator(org.jbehave.core.reporters.ViewGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) Properties(java.util.Properties) ReportsCount(org.jbehave.core.reporters.ReportsCount) File(java.io.File) Test(org.junit.Test)

Aggregations

ViewGenerator (org.jbehave.core.reporters.ViewGenerator)11 File (java.io.File)10 Properties (java.util.Properties)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 OutputStream (java.io.OutputStream)9 PrintStream (java.io.PrintStream)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)9 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)9 Test (org.junit.Test)9 ReportsCount (org.jbehave.core.reporters.ReportsCount)8 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)2 Configuration (org.jbehave.core.configuration.Configuration)1 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)1 EmbedderFailureStrategy (org.jbehave.core.embedder.Embedder.EmbedderFailureStrategy)1 FailingUponPendingStep (org.jbehave.core.failures.FailingUponPendingStep)1