use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.
the class EmbedderBehaviour method shouldFailWhenGeneratingReportsViewWithPendingSteps.
@Test(expected = RunningStoriesFailed.class)
public void shouldFailWhenGeneratingReportsViewWithPendingSteps() 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).usePendingStepStrategy(new FailingUponPendingStep());
File outputDirectory = new File("target/output");
List<String> formats = asList("html");
Properties viewResources = new Properties();
when(viewGenerator.getReportsCount()).thenReturn(new ReportsCount(2, 0, 1, 2, 0, 0, 1, 0));
embedder.generateReportsView(outputDirectory, formats, viewResources);
// Then
verify(viewGenerator).generateReportsView(outputDirectory, formats, viewResources);
assertThatReportsViewGenerated(out);
}
use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.
the class EmbedderBehaviour method shouldHandleFailuresAccordingToStrategy.
@Test
public void shouldHandleFailuresAccordingToStrategy() 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);
EmbedderFailureStrategy failureStategy = mock(EmbedderFailureStrategy.class);
embedder.useEmbedderFailureStrategy(failureStategy);
embedder.configuration().useViewGenerator(viewGenerator);
File outputDirectory = new File("target/output");
List<String> formats = asList("html");
Properties viewResources = new Properties();
// When
ReportsCount count = new ReportsCount(1, 0, 1, 2, 1, 1, 1, 1);
when(viewGenerator.getReportsCount()).thenReturn(count);
embedder.generateReportsView(outputDirectory, formats, viewResources);
// Then
verify(failureStategy).handleFailures(count);
}
use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.
the class EmbedderBehaviour method shouldGenerateReportsViewFromExistingReports.
@Test
public void shouldGenerateReportsViewFromExistingReports() 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, 1, 2, 0, 0, 1, 0));
embedder.generateReportsView(outputDirectory, formats, viewResources);
// Then
verify(viewGenerator).generateReportsView(outputDirectory, formats, viewResources);
assertThatReportsViewGenerated(out);
}
use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.
the class Embedder method generateMapsView.
private void generateMapsView(StoryMaps storyMaps) {
Configuration configuration = configuration();
StoryReporterBuilder builder = configuration.storyReporterBuilder();
File outputDirectory = builder.outputDirectory();
Properties viewResources = builder.viewResources();
ViewGenerator viewGenerator = configuration.viewGenerator();
try {
embedderMonitor.generatingMapsView(outputDirectory, storyMaps, viewResources);
viewGenerator.generateMapsView(outputDirectory, storyMaps, viewResources);
} catch (RuntimeException e) {
embedderMonitor.mapsViewGenerationFailed(outputDirectory, storyMaps, viewResources, e);
throw new ViewGenerationFailed(outputDirectory, storyMaps, viewResources, e);
}
}
use of org.jbehave.core.reporters.ViewGenerator in project jbehave-core by jbehave.
the class EmbedderBehaviour method shouldThrowExceptionIfViewGenerationFails.
@Test(expected = ViewGenerationFailed.class)
public void shouldThrowExceptionIfViewGenerationFails() 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();
doThrow(new RuntimeException()).when(viewGenerator).generateReportsView(outputDirectory, formats, viewResources);
embedder.generateReportsView(outputDirectory, formats, viewResources);
// Then fail as expected
}
Aggregations