Search in sources :

Example 1 with StubPendingException

use of io.cucumber.core.backend.StubPendingException in project cucumber-jvm by cucumber.

the class TestNGFormatterTest method testScenarioWithPendingSteps.

@Test
void testScenarioWithPendingSteps() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature\n" + "  Scenario: scenario\n" + "    When step1\n" + "    Then step2\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new TestNGFormatter(out)).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("step1", new StubPendingException()), new StubStepDefinition("step2"))).build().run();
    String expected = "" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testng-results failed=\"1\" passed=\"0\" skipped=\"0\" total=\"1\">\n" + "    <suite duration-ms=\"0\" name=\"io.cucumber.core.plugin.TestNGFormatter\">\n" + "        <test duration-ms=\"0\" name=\"io.cucumber.core.plugin.TestNGFormatter\">\n" + "            <class name=\"feature\">\n" + "                <test-method duration-ms=\"0\" finished-at=\"1970-01-01T00:00:00Z\" name=\"scenario\" started-at=\"1970-01-01T00:00:00Z\" status=\"FAIL\">\n" + "                    <exception class=\"The scenario has pending or undefined step(s)\">\n" + "                        <message>\n" + "                            <![CDATA[When step1..................................................................pending\n" + "Then step2..................................................................skipped\n" + "]]>\n" + "                        </message>\n" + "                        <full-stacktrace>\n" + "                            <![CDATA[The scenario has pending or undefined step(s)]]>\n" + "                        </full-stacktrace>\n" + "                    </exception>\n" + "                </test-method>\n" + "            </class>\n" + "        </test>\n" + "    </suite>\n" + "</testng-results>\n";
    assertXmlEquals(expected, out);
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) StubPendingException(io.cucumber.core.backend.StubPendingException) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 2 with StubPendingException

use of io.cucumber.core.backend.StubPendingException in project cucumber-jvm by cucumber.

the class RerunFormatterTest method should_put_data_in_report_when_exit_code_is_non_zero.

@Test
void should_put_data_in_report_when_exit_code_is_non_zero() {
    Feature feature = TestFeatureParser.parse("classpath:path/test.feature", "" + "Feature: feature name\n" + "  Scenario: failed scenario\n" + "    Given failed step\n" + "  Scenario: pending scenario\n" + "    Given pending step\n" + "  Scenario: undefined scenario\n" + "    Given undefined step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new RerunFormatter(out)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("failed step", new StubException()), new StubStepDefinition("pending step", new StubPendingException()))).build().run();
    assertThat(out, isBytesEqualTo("classpath:path/test.feature:2:4:6\n"));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) StubPendingException(io.cucumber.core.backend.StubPendingException) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 3 with StubPendingException

use of io.cucumber.core.backend.StubPendingException in project cucumber-jvm by cucumber.

the class JUnitFormatterTest method should_handle_pending_in_before_hook.

@Test
void should_handle_pending_in_before_hook() {
    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 JUnitFormatter(out)).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(singletonList(new StubHookDefinition(new StubPendingException())), Arrays.asList(new StubStepDefinition("first step"), new StubStepDefinition("second step"), new StubStepDefinition("third step")), singletonList(new StubHookDefinition()))).build().run();
    String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"1\" name=\"io.cucumber.core.plugin.JUnitFormatter\" skipped=\"0\" errors=\"0\" tests=\"1\" time=\"0\">\n" + "    <testcase classname=\"feature name\" name=\"scenario name\" time=\"0\">\n" + "        <failure message=\"The scenario has pending or undefined step(s)\" type=\"io.cucumber.core.backend.StubPendingException\">\n" + "            <![CDATA[Given first step............................................................skipped\n" + "When second step............................................................skipped\n" + "Then third step.............................................................skipped\n" + "]]>\n" + "        </failure>\n" + "    </testcase>\n" + "</testsuite>\n";
    assertXmlEqual(expected, out);
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) StubHookDefinition(io.cucumber.core.backend.StubHookDefinition) StubPendingException(io.cucumber.core.backend.StubPendingException) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 4 with StubPendingException

use of io.cucumber.core.backend.StubPendingException in project cucumber-jvm by cucumber.

the class JUnitFormatterTest method should_format_pending_scenario.

@Test
void should_format_pending_scenario() {
    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 JUnitFormatter(out)).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", new StubPendingException()), new StubStepDefinition("second step"), new StubStepDefinition("third step"))).build().run();
    String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite errors=\"0\" failures=\"1\" name=\"io.cucumber.core.plugin.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0\">\n" + "    <testcase classname=\"feature name\" name=\"scenario name\" time=\"0\">\n" + "        <failure message=\"The scenario has pending or undefined step(s)\" type=\"io.cucumber.core.backend.StubPendingException\">\n" + "            <![CDATA[Given first step............................................................pending\n" + "When second step............................................................skipped\n" + "Then third step.............................................................skipped\n" + "]]>\n" + "        </failure>\n" + "    </testcase>\n" + "</testsuite>\n";
    assertXmlEqual(expected, out);
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) StubPendingException(io.cucumber.core.backend.StubPendingException) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 5 with StubPendingException

use of io.cucumber.core.backend.StubPendingException in project cucumber-jvm by cucumber.

the class TeamCityPluginTest method should_print_error_message_for_pending_steps.

@Test
void should_print_error_message_for_pending_steps() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n" + "    Given second step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", new StubPendingException()))).build().run();
    assertThat(out, bytesContainsString("" + "##teamcity[testFailed timestamp = '1970-01-01T12:00:00.000+0000' duration = '0' message = 'Step pending' details = 'TODO: implement me' name = 'first step']"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) PrintStream(java.io.PrintStream) StubPendingException(io.cucumber.core.backend.StubPendingException) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Aggregations

StubPendingException (io.cucumber.core.backend.StubPendingException)5 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)5 Feature (io.cucumber.core.gherkin.Feature)5 StubBackendSupplier (io.cucumber.core.runtime.StubBackendSupplier)5 StubFeatureSupplier (io.cucumber.core.runtime.StubFeatureSupplier)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Test (org.junit.jupiter.api.Test)5 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)4 UUID (java.util.UUID)4 StubHookDefinition (io.cucumber.core.backend.StubHookDefinition)1 PrintStream (java.io.PrintStream)1