use of io.cucumber.core.runtime.StubBackendSupplier in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_output_from_afterStep_hooks.
@Test
void should_print_output_from_afterStep_hooks() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second 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(), emptyList(), asList(new StubStepDefinition("first step", "path/step_definitions.java:3"), new StubStepDefinition("second step", "path/step_definitions.java:4")), singletonList(new StubHookDefinition(testCaseState -> testCaseState.log("printed from afterstep hook"))), emptyList())).build().run();
assertThat(out, bytesContainsString("" + " Given first step # path/step_definitions.java:3\n" + "\n" + " printed from afterstep hook\n" + "\n" + " When second step # path/step_definitions.java:4\n" + "\n" + " printed from afterstep hook" + "\n"));
}
use of io.cucumber.core.runtime.StubBackendSupplier in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_color_code_error_message_according_to_the_result.
@Test
void should_color_code_error_message_according_to_the_result() {
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)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", "path/step_definitions.java:3", new StubException()))).build().run();
assertThat(out, bytesContainsString("" + " " + AnsiEscapes.RED + "the stack trace" + AnsiEscapes.RESET + "\n"));
}
use of io.cucumber.core.runtime.StubBackendSupplier in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_error_message_for_after_hooks.
@Test
void should_print_error_message_for_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(new StubException())))).build().run();
assertThat(out, bytesContainsString("" + " Given first step # path/step_definitions.java:3\n" + " the stack trace\n"));
}
use of io.cucumber.core.runtime.StubBackendSupplier in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_color_code_steps_according_to_the_result.
@Test
void should_color_code_steps_according_to_the_result() {
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)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", "path/step_definitions.java:3"))).build().run();
assertThat(out, bytesContainsString("" + " " + AnsiEscapes.GREEN + "Given " + AnsiEscapes.RESET + AnsiEscapes.GREEN + "first step" + AnsiEscapes.RESET));
}
use of io.cucumber.core.runtime.StubBackendSupplier in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_system_failure_for_failed_hooks.
@Test
void should_print_system_failure_for_failed_hooks() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
assertThrows(StubException.class, () -> Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withBackendSupplier(new StubBackendSupplier(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), singletonList(new StubStaticHookDefinition(new StubException("Hook failed", "the stack trace"))))).build().run());
assertThat(out, bytesContainsString("" + " " + AnsiEscapes.RED + "the stack trace" + AnsiEscapes.RESET + "\n"));
}
Aggregations