use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_failed_scenario.
@Test
void should_format_failed_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 StubStepDefinition("second step"), new StubStepDefinition("third step", new StubException("the message", "the stack trace")))).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 message\" type=\"io.cucumber.core.plugin.StubException\"><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................failed\n" + "\n" + "StackTrace:\n" + "the stack trace]]></failure>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, out);
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_handle_failure_in_before_hook_with_background.
@Test
void should_handle_failure_in_before_hook_with_background() {
Feature feature = TestFeatureParser.parse("path/test.feature", "Feature: feature name\n" + " Background: background name\n" + " Given first step\n" + " Scenario: scenario name\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 StubException("the message", "the stack trace"))), 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 message\" type=\"io.cucumber.core.plugin.StubException\"><![CDATA[" + "Given first step............................................................skipped\n" + "When second step............................................................skipped\n" + "Then third step.............................................................skipped\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, out);
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_use_scenario_location_when_scenario_step_fails.
@Test
void should_use_scenario_location_when_scenario_step_fails() {
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 RerunFormatter(out)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step"), new StubStepDefinition("second step"), new StubStepDefinition("third step", new StubException()))).build().run();
assertThat(out, isBytesEqualTo("file:path/test.feature:2\n"));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_use_scenario_location_when_before_hook_fails.
@Test
void should_use_scenario_location_when_before_hook_fails() {
Feature feature = TestFeatureParser.parse("classpath: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 RerunFormatter(out)).withBackendSupplier(new StubBackendSupplier(singletonList(new StubHookDefinition(new StubException())), asList(new StubStepDefinition("first step"), new StubStepDefinition("second step"), new StubStepDefinition("third step")), emptyList())).build().run();
assertThat(out, isBytesEqualTo("classpath:path/test.feature:2\n"));
}
use of io.cucumber.core.gherkin.Feature 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"));
}
Aggregations