use of io.cucumber.core.runtime.StubFeatureSupplier in project cucumber-jvm by cucumber.
the class JsonFormatterTest method should_format_scenario_outline_with_one_example.
@Test
void should_format_scenario_outline_with_one_example() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: Fruit party\n" + "\n" + " Scenario Outline: Monkey eats fruits\n" + " Given there are <fruits>\n" + " Examples: Fruit table\n" + " | fruits |\n" + " | 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(new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()"))).build().run();
String expected = "" + "[\n" + " {\n" + " \"id\": \"fruit-party\",\n" + " \"uri\": \"file:path/test.feature\",\n" + " \"keyword\": \"Feature\",\n" + " \"name\": \"Fruit party\",\n" + " \"line\": 1,\n" + " \"description\": \"\",\n" + " \"elements\": [\n" + " {\n" + " \"id\": \"fruit-party;monkey-eats-fruits;fruit-table;2\",\n" + " \"keyword\": \"Scenario Outline\",\n" + " \"start_timestamp\": \"1970-01-01T00:00:00.000Z\",\n" + " \"name\": \"Monkey eats fruits\",\n" + " \"line\": 7,\n" + " \"description\": \"\",\n" + " \"type\": \"scenario\",\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" + " }\n" + " ],\n" + " \"tags\": []\n" + " }\n" + "]";
assertJsonEquals(expected, out);
}
use of io.cucumber.core.runtime.StubFeatureSupplier in project cucumber-jvm by cucumber.
the class JsonFormatterTest method should_format_scenario_with_a_step_with_a_doc_string.
@Test
void should_format_scenario_with_a_step_with_a_doc_string() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: Banana party\n" + "\n" + " Scenario: Monkey eats bananas\n" + " Given there are bananas\n" + " \"\"\"\n" + " doc string content\n" + " \"\"\"\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(new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()", String.class))).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" + " \"steps\": [\n" + " {\n" + " \"keyword\": \"Given \",\n" + " \"name\": \"there are bananas\",\n" + " \"line\": 4,\n" + " \"doc_string\": {\n" + " \"value\": \"doc string content\",\n" + " \"line\": 5\n" + " },\n" + " \"match\": {\n" + " \"location\": \"StepDefs.there_are_bananas()\"\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.runtime.StubFeatureSupplier in project cucumber-jvm by cucumber.
the class JsonFormatterTest method should_format_feature_with_background.
@Test
void should_format_feature_with_background() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: Banana party\n" + "\n" + " Background: There are bananas\n" + " Given there are bananas\n" + "\n" + " Scenario: Monkey eats bananas\n" + " Then the monkey eats bananas\n" + "\n" + " Scenario: Monkey eats more bananas\n" + " Then the monkey eats more 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(new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()"), new StubStepDefinition("the monkey eats bananas", "StepDefs.monkey_eats_bananas()"), new StubStepDefinition("the monkey eats more bananas", "StepDefs.monkey_eats_more_bananas()"))).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" + " \"keyword\": \"Background\",\n" + " \"name\": \"There are bananas\",\n" + " \"line\": 3,\n" + " \"description\": \"\",\n" + " \"type\": \"background\",\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" + " },\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\": 6,\n" + " \"description\": \"\",\n" + " \"type\": \"scenario\",\n" + " \"steps\": [\n" + " {\n" + " \"keyword\": \"Then \",\n" + " \"name\": \"the monkey eats bananas\",\n" + " \"line\": 7,\n" + " \"match\": {\n" + " \"location\": \"StepDefs.monkey_eats_bananas()\"\n" + " },\n" + " \"result\": {\n" + " \"status\": \"passed\",\n" + " \"duration\": 1000000\n" + " }\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"keyword\": \"Background\",\n" + " \"name\": \"There are bananas\",\n" + " \"line\": 3,\n" + " \"description\": \"\",\n" + " \"type\": \"background\",\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" + " },\n" + " {\n" + " \"id\": \"banana-party;monkey-eats-more-bananas\",\n" + " \"keyword\": \"Scenario\",\n" + " \"start_timestamp\": \"1970-01-01T00:00:00.002Z\",\n" + " \"name\": \"Monkey eats more bananas\",\n" + " \"line\": 9,\n" + " \"description\": \"\",\n" + " \"type\": \"scenario\",\n" + " \"steps\": [\n" + " {\n" + " \"keyword\": \"Then \",\n" + " \"name\": \"the monkey eats more bananas\",\n" + " \"line\": 10,\n" + " \"match\": {\n" + " \"location\": \"StepDefs.monkey_eats_more_bananas()\"\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.runtime.StubFeatureSupplier in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_passed_scenario.
@Test
void should_format_passed_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"))).build().run();
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" 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" + " <system-out><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, out);
}
use of io.cucumber.core.runtime.StubFeatureSupplier in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_multiple_scenarios.
@Test
void should_format_multiple_scenarios() {
Feature feature = TestFeatureParser.parse("path/test.feature", "Feature: feature name\n" + " Scenario: First scenario\n" + " Given first step\n" + " When second step\n" + " Then third step\n" + " Scenario: Second scenario\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"))).build().run();
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite errors=\"0\" failures=\"0\" name=\"io.cucumber.core.plugin.JUnitFormatter\" skipped=\"0\" tests=\"2\" time=\"0\">\n" + " <testcase classname=\"feature name\" name=\"First scenario\" time=\"0\">\n" + " <system-out>\n" + " <![CDATA[Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]>\n" + " </system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"Second scenario\" time=\"0\">\n" + " <system-out>\n" + " <![CDATA[Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]>\n" + " </system-out>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, out);
}
Aggregations