Search in sources :

Example 11 with PluginOption

use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.

the class PluginFactoryTest method fails_to_instantiate_plugin_that_declares_two_single_arg_constructors_when_no_argument_specified.

@Test
void fails_to_instantiate_plugin_that_declares_two_single_arg_constructors_when_no_argument_specified() {
    PluginOption option = parse(WantsFileOrURL.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$WantsFileOrURL. Like so: io.cucumber.core.plugin.PluginFactoryTest$WantsFileOrURL:DIR|FILE|URL")));
}
Also used : PluginOption(io.cucumber.core.options.PluginOption) CucumberException(io.cucumber.core.exception.CucumberException) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 12 with PluginOption

use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.

the class PluginFactoryTest method instantiates_rerun_plugin_with_file_arg.

@Test
void instantiates_rerun_plugin_with_file_arg() {
    PluginOption option = parse("rerun:" + tmp.resolve("rerun.txt"));
    plugin = fc.create(option);
    assertThat(plugin.getClass(), is(equalTo(RerunFormatter.class)));
}
Also used : PluginOption(io.cucumber.core.options.PluginOption) Test(org.junit.jupiter.api.Test)

Example 13 with PluginOption

use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.

the class PluginFactoryTest method cant_create_plugin_when_file_is_a_directory.

@Test
void cant_create_plugin_when_file_is_a_directory() {
    Path jsonReport = tmp.resolve("target/cucumber/reports/cucumber.json");
    PluginOption jsonOption = parse("json:" + jsonReport);
    plugin = fc.create(jsonOption);
    Path htmlReport = tmp.resolve("target/cucumber/reports");
    PluginOption htmlOption = parse("html:" + htmlReport);
    IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> fc.create(htmlOption));
    assertThat(exception.getMessage(), is(equalTo("Couldn't create a file output stream for '" + htmlReport + "'.\n" + "Make sure the the file isn't a directory.\n" + "\n" + "Note: This usually happens when plugins write to colliding paths.\n" + "For example: 'json:target/cucumber/report.json, html:target/cucumber'\n" + "You can fix this by making the paths do no collide.\n" + "For example: 'json:target/cucumber/report.json, html:target/cucumber/report.html'\n" + "The details are in the stack trace below:")));
}
Also used : Path(java.nio.file.Path) PluginOption(io.cucumber.core.options.PluginOption) Test(org.junit.jupiter.api.Test)

Example 14 with PluginOption

use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.

the class PluginFactoryTest method instantiates_custom_file_plugin.

@Test
void instantiates_custom_file_plugin() {
    PluginOption option = parse(WantsFile.class.getName() + ":halp.txt");
    WantsFile plugin = (WantsFile) fc.create(option);
    assertThat(plugin.out, is(equalTo(new File("halp.txt"))));
}
Also used : PluginOption(io.cucumber.core.options.PluginOption) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 15 with PluginOption

use of io.cucumber.core.options.PluginOption in project cucumber-jvm by cucumber.

the class PluginFactoryTest method instantiates_file_or_empty_arg_plugin_with_arg.

@Test
void instantiates_file_or_empty_arg_plugin_with_arg() {
    PluginOption option = parse(WantsFileOrEmpty.class.getName() + ":" + tmp.resolve("out.txt"));
    WantsFileOrEmpty plugin = (WantsFileOrEmpty) fc.create(option);
    assertThat(plugin.out, is(notNullValue()));
}
Also used : PluginOption(io.cucumber.core.options.PluginOption) Test(org.junit.jupiter.api.Test)

Aggregations

PluginOption (io.cucumber.core.options.PluginOption)23 Test (org.junit.jupiter.api.Test)23 CucumberException (io.cucumber.core.exception.CucumberException)5 Path (java.nio.file.Path)4 Executable (org.junit.jupiter.api.function.Executable)4 EventBus (io.cucumber.core.eventbus.EventBus)1 ClockStub (io.cucumber.core.runner.ClockStub)1 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)1 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)1 Result (io.cucumber.plugin.event.Result)1 TestCase (io.cucumber.plugin.event.TestCase)1 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 UUID (java.util.UUID)1