Search in sources :

Example 6 with RuntimeOptionsBuilder

use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.

the class PrettyFormatterTest method should_print_error_message_for_before_hooks.

@Test
void should_print_error_message_for_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(new StubException())), singletonList(new StubStepDefinition("first step", "path/step_definitions.java:3")), emptyList())).build().run();
    assertThat(out, bytesContainsString("" + "Scenario: scenario name # path/test.feature:2\n" + "      the stack trace\n" + "  Given first step      # path/step_definitions.java:3\n"));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) StubHookDefinition(io.cucumber.core.backend.StubHookDefinition) RuntimeOptionsBuilder(io.cucumber.core.options.RuntimeOptionsBuilder) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 7 with RuntimeOptionsBuilder

use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.

the class PrettyFormatterTest method should_align_the_indentation_of_location_strings.

@Test
void should_align_the_indentation_of_location_strings() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n" + "    When second step\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, isBytesEqualTo("" + "\n" + "Scenario: scenario name # path/test.feature:2\n" + "  Given first step      # path/step_definitions.java:3\n" + "  When second step      # path/step_definitions.java:7\n" + "  Then third step       # path/step_definitions.java:11\n"));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) RuntimeOptionsBuilder(io.cucumber.core.options.RuntimeOptionsBuilder) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 8 with RuntimeOptionsBuilder

use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.

the class PrettyFormatterTest method should_print_table.

@Test
void should_print_table() {
    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");
    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))).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"));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) RuntimeOptionsBuilder(io.cucumber.core.options.RuntimeOptionsBuilder) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 9 with RuntimeOptionsBuilder

use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.

the class PrettyFormatterTest method should_handle_scenario_outline.

@Test
void should_handle_scenario_outline() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario Outline: <name>\n" + "    Given first step\n" + "    Then <arg> step\n" + "    Examples: examples name\n" + "      |  name  |  arg   |\n" + "      | name 1 | second |\n" + "      | name 2 | third  |\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 Outline: name 1 # path/test.feature:7\n" + "  Given first step       # path/step_definitions.java:3\n" + "  Then second step       # path/step_definitions.java:7\n" + "\n" + "Scenario Outline: name 2 # path/test.feature:8\n" + "  Given first step       # path/step_definitions.java:3\n" + "  Then third step        # path/step_definitions.java:11\n"));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) RuntimeOptionsBuilder(io.cucumber.core.options.RuntimeOptionsBuilder) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 10 with RuntimeOptionsBuilder

use of io.cucumber.core.options.RuntimeOptionsBuilder in project cucumber-jvm by cucumber.

the class PrettyFormatterTest method should_print_error_message_for_failed_steps.

@Test
void should_print_error_message_for_failed_steps() {
    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(new StubStepDefinition("first step", "path/step_definitions.java:3", new StubException()))).build().run();
    assertThat(out, bytesContainsString("" + "  Given first step      # path/step_definitions.java:3\n" + "      the stack trace\n"));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) RuntimeOptionsBuilder(io.cucumber.core.options.RuntimeOptionsBuilder) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Aggregations

RuntimeOptionsBuilder (io.cucumber.core.options.RuntimeOptionsBuilder)28 Test (org.junit.jupiter.api.Test)27 Feature (io.cucumber.core.gherkin.Feature)20 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)16 ByteArrayOutputStream (java.io.ByteArrayOutputStream)16 StubBackendSupplier (io.cucumber.core.runtime.StubBackendSupplier)13 StubFeatureSupplier (io.cucumber.core.runtime.StubFeatureSupplier)13 Collections.emptyList (java.util.Collections.emptyList)7 Collections.singletonList (java.util.Collections.singletonList)7 EventBus (io.cucumber.core.eventbus.EventBus)6 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)6 UUID (java.util.UUID)6 StubHookDefinition (io.cucumber.core.backend.StubHookDefinition)5 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)5 Clock (java.time.Clock)5 Arrays.asList (java.util.Arrays.asList)5 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 IsEqual.equalTo (org.hamcrest.core.IsEqual.equalTo)5 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)5 Glue (io.cucumber.core.backend.Glue)4