use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_output_from_before_hooks.
@Test
void should_print_output_from_before_hooks() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build()).withBackendSupplier(new StubBackendSupplier(singletonList(new StubHookDefinition(testCaseState -> testCaseState.log("printed from hook"))), singletonList(new StubStepDefinition("first step", "path/step_definitions.java:3")), emptyList())).build().run();
assertThat(out, bytesContainsString("" + "Scenario: scenario name # path/test.feature:2\n" + "\n" + " printed from hook\n" + "\n" + " Given first step # path/step_definitions.java:3\n"));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class JsonParallelRuntimeTest method testSingleFeature.
@Test
void testSingleFeature() {
ByteArrayOutputStream parallel = new ByteArrayOutputStream();
Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(3).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/JsonPrettyFormatterTest.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")).build()).withAdditionalPlugins(new JsonFormatter(serial)).withEventBus(new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID)).build().run();
assertThat(parallel.toString(), sameJSONAs(serial.toString()).allowingAnyArrayOrdering());
}
use of io.cucumber.core.options.RuntimeOptionsBuilder 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());
}
Aggregations