Search in sources :

Example 56 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class JsonParallelRuntimeTest method testMultipleFeatures.

@Test
void testMultipleFeatures() {
    ByteArrayOutputStream parallel = new ByteArrayOutputStream();
    Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(3).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/JsonPrettyFormatterTest.feature")).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/FormatterInParallel.feature")).build()).withAdditionalPlugins(new JsonFormatter(parallel)).withEventBus(new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID)).build().run();
    ByteArrayOutputStream serial = new ByteArrayOutputStream();
    Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(1).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/JsonPrettyFormatterTest.feature")).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/FormatterInParallel.feature")).build()).withAdditionalPlugins(new JsonFormatter(serial)).withEventBus(new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID)).build().run();
    assertThat(parallel.toString(), sameJSONAs(serial.toString()).allowingAnyArrayOrdering());
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) RuntimeOptionsBuilder(io.cucumber.core.options.RuntimeOptionsBuilder) ClockStub(io.cucumber.core.runner.ClockStub) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 57 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class CommandlineOptionsParserTest method creates_default_summary_printer_for_deprecated_default_summary_argument.

@Test
void creates_default_summary_printer_for_deprecated_default_summary_argument() {
    RuntimeOptions options = parser.parse("--plugin default_summary").addDefaultSummaryPrinterIfNotDisabled().build();
    Plugins plugins = new Plugins(new PluginFactory(), options);
    plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    assertThat(plugins.getPlugins(), hasItem(plugin("io.cucumber.core.plugin.DefaultSummaryPrinter")));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PluginFactory(io.cucumber.core.plugin.PluginFactory) Plugins(io.cucumber.core.plugin.Plugins) Test(org.junit.jupiter.api.Test)

Example 58 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class CommandlineOptionsParserTest method set_monochrome_on_color_aware_formatters.

@Test
void set_monochrome_on_color_aware_formatters() {
    RuntimeOptions options = parser.parse("--monochrome", "--plugin", AwareFormatter.class.getName()).build();
    Plugins plugins = new Plugins(new PluginFactory(), options);
    plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    AwareFormatter formatter = (AwareFormatter) plugins.getPlugins().get(0);
    assertThat(formatter.isMonochrome(), is(true));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PluginFactory(io.cucumber.core.plugin.PluginFactory) Plugins(io.cucumber.core.plugin.Plugins) Test(org.junit.jupiter.api.Test)

Example 59 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class CommandlineOptionsParserTest method creates_html_formatter.

@Test
void creates_html_formatter() {
    RuntimeOptions options = parser.parse("--plugin", "html:target/deeply/nested.html", "--glue", "somewhere").build();
    Plugins plugins = new Plugins(new PluginFactory(), options);
    plugins.setEventBusOnEventListenerPlugins(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
    assertThat(plugins.getPlugins().get(0).getClass().getName(), is("io.cucumber.core.plugin.HtmlFormatter"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) PluginFactory(io.cucumber.core.plugin.PluginFactory) Plugins(io.cucumber.core.plugin.Plugins) Test(org.junit.jupiter.api.Test)

Example 60 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class HtmlFormatterTest method writes_index_html.

@Test
void writes_index_html() throws Throwable {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    HtmlFormatter formatter = new HtmlFormatter(bytes);
    EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
    formatter.setEventPublisher(bus);
    TestRunStarted testRunStarted = new TestRunStarted();
    testRunStarted.setTimestamp(new Timestamp(10L, 0L));
    Envelope testRunStartedEnvelope = new Envelope();
    testRunStartedEnvelope.setTestRunStarted(testRunStarted);
    bus.send(testRunStartedEnvelope);
    TestRunFinished testRunFinished = new TestRunFinished();
    testRunFinished.setTimestamp(new Timestamp(15L, 0L));
    Envelope testRunFinishedEnvelope = new Envelope();
    testRunFinishedEnvelope.setTestRunFinished(testRunFinished);
    bus.send(testRunFinishedEnvelope);
    String html = new String(bytes.toByteArray(), UTF_8);
    assertThat(html, containsString("" + "window.CUCUMBER_MESSAGES = [" + "{\"testRunStarted\":{\"timestamp\":{\"seconds\":10,\"nanos\":0}}}," + "{\"testRunFinished\":{\"timestamp\":{\"seconds\":15,\"nanos\":0}}}" + "];\n"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) TestRunStarted(io.cucumber.messages.types.TestRunStarted) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) EventBus(io.cucumber.core.eventbus.EventBus) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) UUID(java.util.UUID) Envelope(io.cucumber.messages.types.Envelope) TestRunFinished(io.cucumber.messages.types.TestRunFinished) Timestamp(io.cucumber.messages.types.Timestamp) Test(org.junit.jupiter.api.Test)

Aggregations

TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)80 Test (org.junit.jupiter.api.Test)77 UUID (java.util.UUID)63 ByteArrayOutputStream (java.io.ByteArrayOutputStream)59 Feature (io.cucumber.core.gherkin.Feature)55 StubBackendSupplier (io.cucumber.core.runtime.StubBackendSupplier)53 StubFeatureSupplier (io.cucumber.core.runtime.StubFeatureSupplier)52 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)46 StubHookDefinition (io.cucumber.core.backend.StubHookDefinition)19 StepDurationTimeService (io.cucumber.core.runner.StepDurationTimeService)19 DocString (io.cucumber.docstring.DocString)17 PluginFactory (io.cucumber.core.plugin.PluginFactory)13 Plugins (io.cucumber.core.plugin.Plugins)13 PrintStream (java.io.PrintStream)12 EventBus (io.cucumber.core.eventbus.EventBus)11 RuntimeOptionsBuilder (io.cucumber.core.options.RuntimeOptionsBuilder)6 StubPendingException (io.cucumber.core.backend.StubPendingException)4 TestCaseState (io.cucumber.core.backend.TestCaseState)4 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)4 DataTable (io.cucumber.datatable.DataTable)4