use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class JsonFormatterTest method should_format_scenario_with_hooks.
@Test
void should_format_scenario_with_hooks() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: Banana party\n" + "\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(singletonList(new StubHookDefinition("Hooks.before_hook_1()")), singletonList(new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()")), singletonList(new StubHookDefinition("Hooks.after_hook_1()")))).build().run();
String expected = "" + "[\n" + " {\n" + " \"id\": \"banana-party\",\n" + " \"uri\": \"file:path/test.feature\",\n" + " \"keyword\": \"Feature\",\n" + " \"name\": \"Banana party\",\n" + " \"line\": 1,\n" + " \"description\": \"\",\n" + " \"elements\": [\n" + " {\n" + " \"id\": \"banana-party;monkey-eats-bananas\",\n" + " \"keyword\": \"Scenario\",\n" + " \"start_timestamp\": \"1970-01-01T00:00:00.000Z\",\n" + " \"name\": \"Monkey eats bananas\",\n" + " \"line\": 3,\n" + " \"description\": \"\",\n" + " \"type\": \"scenario\",\n" + " \"before\": [\n" + " {\n" + " \"match\": {\n" + " \"location\": \"Hooks.before_hook_1()\"\n" + " },\n" + " \"result\": {\n" + " \"status\": \"passed\",\n" + " \"duration\": 1000000\n" + " }\n" + " }\n" + " ],\n" + " \"steps\": [\n" + " {\n" + " \"keyword\": \"Given \",\n" + " \"name\": \"there are bananas\",\n" + " \"line\": 4,\n" + " \"match\": {\n" + " \"location\": \"StepDefs.there_are_bananas()\"\n" + " },\n" + " \"result\": {\n" + " \"status\": \"passed\",\n" + " \"duration\": 1000000\n" + " }\n" + " }\n" + " ],\n" + " \"after\": [\n" + " {\n" + " \"match\": {\n" + " \"location\": \"Hooks.after_hook_1()\"\n" + " },\n" + " \"result\": {\n" + " \"status\": \"passed\",\n" + " \"duration\": 1000000\n" + " }\n" + " }\n" + " ]\n" + " }\n" + " ],\n" + " \"tags\": []\n" + " }\n" + "]";
assertJsonEquals(expected, out);
}
use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_leave_report_empty_when_exit_code_is_zero.
@Test
void should_leave_report_empty_when_exit_code_is_zero() {
Feature feature = TestFeatureParser.parse("classpath:path/test.feature", "" + "Feature: feature name\n" + " Scenario: passed scenario\n" + " Given passed step\n" + " Scenario: skipped scenario\n" + " Given skipped step\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new RerunFormatter(out)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("passed step"), new StubStepDefinition("skipped step", new TestAbortedException()))).build().run();
assertThat(out, isBytesEqualTo(""));
}
use of io.cucumber.core.backend.StubStepDefinition 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']"));
}
use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class TeamCityPluginTest method should_handle_attach_events.
@Test
void should_handle_attach_events() {
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 TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(singletonList(new StubHookDefinition((TestCaseState state) -> state.attach("A message", "text/plain", "message.txt"))), singletonList(new StubStepDefinition("first step")), emptyList())).build().run();
assertThat(out, bytesContainsString("" + "##teamcity[message text='Embed event: message.txt |[text/plain 9 bytes|]|n' status='NORMAL']\n"));
}
use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class TeamCityPluginTest 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 TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", new StubException("Step failed", "the stack trace")))).build().run();
assertThat(out, bytesContainsString("" + "##teamcity[testFailed timestamp = '1970-01-01T12:00:00.000+0000' duration = '0' message = 'Step failed' details = 'the stack trace' name = 'first step']\n"));
}
Aggregations