use of io.cucumber.core.runtime.StubFeatureSupplier 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.StubFeatureSupplier 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.StubFeatureSupplier 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.StubFeatureSupplier 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"));
}
use of io.cucumber.core.runtime.StubFeatureSupplier in project cucumber-jvm by cucumber.
the class JsonFormatterTest method should_format_scenario_with_a_rule.
@Test
void should_format_scenario_with_a_rule() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: Banana party\n" + "\n" + " Rule: This is all monkey business\n" + " Scenario: Monkey eats bananas\n" + " Given there are bananas\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
StepDurationTimeService timeService = new StepDurationTimeService(ofMillis(1));
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(timeService, new JsonFormatter(out)).withEventBus(new TimeServiceEventBus(timeService, UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()"))).build().run();
String expected = "" + "[\n" + " {\n" + " \"line\": 1,\n" + " \"elements\": [\n" + " {\n" + " \"start_timestamp\": \"1970-01-01T00:00:00.000Z\",\n" + " \"line\": 4,\n" + " \"name\": \"Monkey eats bananas\",\n" + " \"description\": \"\",\n" + " \"id\": \";monkey-eats-bananas\",\n" + " \"type\": \"scenario\",\n" + " \"keyword\": \"Scenario\",\n" + " \"steps\": [\n" + " {\n" + " \"result\": {\n" + " \"duration\": 1000000,\n" + " \"status\": \"passed\"\n" + " },\n" + " \"line\": 5,\n" + " \"name\": \"there are bananas\",\n" + " \"match\": {\n" + " \"location\": \"StepDefs.there_are_bananas()\"\n" + " },\n" + " \"keyword\": \"Given \"\n" + " }\n" + " ]\n" + " }\n" + " ],\n" + " \"name\": \"Banana party\",\n" + " \"description\": \"\",\n" + " \"id\": \"banana-party\",\n" + " \"keyword\": \"Feature\",\n" + " \"uri\": \"file:path/test.feature\",\n" + " \"tags\": []\n" + " }\n" + "]";
assertJsonEquals(expected, out);
}
Aggregations