use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class RuntimeTest method should_fail_on_event_listener_exception_when_running_in_parallel.
@Test
void should_fail_on_event_listener_exception_when_running_in_parallel() {
Feature feature1 = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name 1\n" + " Scenario: scenario_1 name\n" + " Given first step\n" + " Scenario: scenario_2 name\n" + " Given first step\n");
Feature feature2 = TestFeatureParser.parse("path/test2.feature", "" + "Feature: feature name 2\n" + " Scenario: scenario_2 name\n" + " Given first step\n");
ConcurrentEventListener brokenEventListener = publisher -> publisher.registerHandlerFor(TestStepFinished.class, (TestStepFinished event) -> {
throw new RuntimeException("This exception is expected");
});
Executable testMethod = () -> Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature1, feature2)).withAdditionalPlugins(brokenEventListener).withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(2).build()).build().run();
CompositeCucumberException actualThrown = assertThrows(CompositeCucumberException.class, testMethod);
assertThat(actualThrown.getMessage(), is(equalTo("There were 3 exceptions. The details are in the stacktrace below.")));
assertThat(actualThrown.getSuppressed(), is(arrayWithSize(3)));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_output_from_after_hooks.
@Test
void should_print_output_from_after_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(emptyList(), singletonList(new StubStepDefinition("first step", "path/step_definitions.java:3")), singletonList(new StubHookDefinition(testCaseState -> testCaseState.log("printed from hook"))))).build().run();
assertThat(out, bytesContainsString("" + " Given first step # path/step_definitions.java:3\n" + "\n" + " printed from hook\n"));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_handle_background.
@Test
void should_handle_background() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + " Background: background name\n" + " Given first step\n" + " Scenario: s1\n" + " Then second step\n" + " Scenario: s2\n" + " Then third step\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build()).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", "path/step_definitions.java:3"), new StubStepDefinition("second step", "path/step_definitions.java:7"), new StubStepDefinition("third step", "path/step_definitions.java:11"))).build().run();
assertThat(out, bytesContainsString("" + "\n" + "Scenario: s1 # path/test.feature:4\n" + " Given first step # path/step_definitions.java:3\n" + " Then second step # path/step_definitions.java:7\n" + "\n" + "Scenario: s2 # path/test.feature:6\n" + " Given first step # path/step_definitions.java:3\n" + " Then third step # path/step_definitions.java:11\n"));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_tags.
@Test
void should_print_tags() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "@feature_tag\n" + "Feature: feature name\n" + " @scenario_tag\n" + " Scenario: scenario name\n" + " Then first step\n" + " @scenario_outline_tag\n" + " Scenario Outline: scenario outline name\n" + " Then <arg> step\n" + " @examples_tag\n" + " Examples: examples name\n" + " | arg |\n" + " | second |\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build()).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", "path/step_definitions.java:7"), new StubStepDefinition("second step", "path/step_definitions.java:11"))).build().run();
assertThat(out, isBytesEqualTo("" + "\n" + "@feature_tag @scenario_tag\n" + "Scenario: scenario name # path/test.feature:4\n" + " Then first step # path/step_definitions.java:7\n" + "\n" + "@feature_tag @scenario_outline_tag @examples_tag\n" + "Scenario Outline: scenario outline name # path/test.feature:12\n" + " Then second step # path/step_definitions.java:11\n"));
}
use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_multiple_tables.
@Test
void should_print_multiple_tables() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: Test feature\n" + " Scenario: Test Scenario\n" + " Given first step\n" + " | key1 | key2 |\n" + " | value1 | value2 |\n" + " | another1 | another2 |\n" + " Given second step\n" + " | key3 | key4 |\n" + " | value3 | value4 |\n" + " | another3 | another4 |\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build()).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", "path/step_definitions.java:7", DataTable.class), new StubStepDefinition("second step", "path/step_definitions.java:15", DataTable.class))).build().run();
assertThat(out, isBytesEqualTo("" + "\n" + "Scenario: Test Scenario # path/test.feature:2\n" + " Given first step # path/step_definitions.java:7\n" + " | key1 | key2 |\n" + " | value1 | value2 |\n" + " | another1 | another2 |\n" + " Given second step # path/step_definitions.java:15\n" + " | key3 | key4 |\n" + " | value3 | value4 |\n" + " | another3 | another4 |\n"));
}
Aggregations