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);
}
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"));
}
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);
}
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);
}
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']"));
}
Aggregations