use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.
the class PluginFactoryTest method fails_to_instantiate_plugin_that_wants_a_file_without_file_arg.
@Test
void fails_to_instantiate_plugin_that_wants_a_file_without_file_arg() {
PluginOption option = parse(WantsFile.class.getName());
Executable testMethod = () -> fc.create(option);
CucumberException exception = assertThrows(CucumberException.class, testMethod);
assertThat(exception.getMessage(), is(equalTo("You must supply an output argument to io.cucumber.core.plugin.PluginFactoryTest$WantsFile. Like so: io.cucumber.core.plugin.PluginFactoryTest$WantsFile:DIR|FILE|URL")));
}
use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.
the class PluginFactoryTest method instantiates_usage_plugin_with_file_arg.
@Test
void instantiates_usage_plugin_with_file_arg() {
PluginOption option = parse("usage:" + tmp.resolve("out.txt").toAbsolutePath());
plugin = fc.create(option);
assertThat(plugin.getClass(), is(equalTo(UsageFormatter.class)));
}
use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.
the class PluginFactoryTest method cant_create_plugin_when_parent_directory_is_a_file.
@Test
void cant_create_plugin_when_parent_directory_is_a_file() throws IOException {
Path htmlReport = tmp.resolve("target/cucumber/reports");
PluginOption htmlOption = parse("html:" + htmlReport);
plugin = fc.create(htmlOption);
Path jsonReport = tmp.resolve("target/cucumber/reports/cucumber.json");
PluginOption jsonOption = parse("json:" + jsonReport);
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> fc.create(jsonOption));
assertThat(exception.getMessage(), is(equalTo("Couldn't create parent directories of '" + jsonReport.toFile().getCanonicalPath() + "'.\n" + "Make sure the the parent directory '" + jsonReport.getParent().toFile().getCanonicalPath() + "' isn't a file.\n" + "\n" + "Note: This usually happens when plugins write to colliding paths.\n" + "For example: 'html:target/cucumber, json:target/cucumber/report.json'\n" + "You can fix this by making the paths do no collide.\n" + "For example: 'html:target/cucumber/report.html, json:target/cucumber/report.json'\n" + "The details are in the stack trace below:")));
}
use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.
the class PluginFactoryTest method plugin_does_not_buffer_its_output.
@Test
void plugin_does_not_buffer_its_output() {
PrintStream previousSystemOut = System.out;
OutputStream mockSystemOut = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(mockSystemOut));
// Need to create a new plugin factory here since we need it to pick
// up the new value of System.out
fc = new PluginFactory();
PluginOption option = parse("progress");
ProgressFormatter plugin = (ProgressFormatter) fc.create(option);
EventBus bus = new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID);
plugin.setEventPublisher(bus);
Result result = new Result(Status.PASSED, ZERO, null);
TestStepFinished event = new TestStepFinished(bus.getInstant(), mock(TestCase.class), mock(PickleStepTestStep.class), result);
bus.send(event);
assertThat(mockSystemOut.toString(), is(not(equalTo(""))));
} finally {
System.setOut(previousSystemOut);
}
}
use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.
the class PluginFactoryTest method instantiates_custom_deprecated_appendable_arg_plugin.
@Test
void instantiates_custom_deprecated_appendable_arg_plugin() throws IOException {
Path tempDirPath = tmp.resolve("out.txt").toAbsolutePath();
PluginOption option = parse(WantsAppendable.class.getName() + ":" + tempDirPath);
WantsAppendable plugin = (WantsAppendable) fc.create(option);
plugin.writeAndClose("hello");
String written = String.join("", readAllLines(tempDirPath));
assertThat(written, is(equalTo("hello")));
}
Aggregations