use of org.jbehave.core.io.StoryLocation in project jbehave-core by jbehave.
the class FilePrintStreamFactoryBehaviour method ensureOutputFileIsSame.
private void ensureOutputFileIsSame(URL codeLocation, String storyPath) {
FileConfiguration configuration = new FileConfiguration("ext");
FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration);
factory.createPrintStream();
File outputFile = factory.getOutputFile();
String expected = new File(codeLocation.getFile()).getParent().replace('\\', '/') + "/" + configuration.getRelativeDirectory() + "/" + "org.jbehave.examples.trader.stories.my_given." + configuration.getExtension();
assertThat(outputFile.toString().replace('\\', '/'), equalTo(expected));
}
use of org.jbehave.core.io.StoryLocation 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"));
}
Aggregations