use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class DryRunTest method dry_run_passes_pending_step.
@Test
void dry_run_passes_pending_step() {
Feature pending = TestFeatureParser.parse("2/pending.feature", "Feature: pending\n" + " Scenario: pending\n" + " * pending step\n");
StepStatusSpy out = new StepStatusSpy();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(pending)).withAdditionalPlugins(out).withBackendSupplier(backend).withRuntimeOptions(new RuntimeOptionsBuilder().setDryRun().build()).build().run();
assertThat(out.toString(), is("" + "pending\n" + " PASSED\n"));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method ignores_identical_features_in_different_directories.
@Test
void ignores_identical_features_in_different_directories() {
URI featurePath1 = URI.create("src/example.feature");
URI featurePath2 = URI.create("build/example.feature");
Feature resource1 = createResourceMock(featurePath1);
Feature resource2 = createResourceMock(featurePath2);
builder.addUnique(resource1);
builder.addUnique(resource2);
List<Feature> features = builder.build();
assertThat(features.size(), equalTo(1));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method duplicate_content_with_different_file_names_are_intentionally_duplicated.
@Test
void duplicate_content_with_different_file_names_are_intentionally_duplicated() {
URI featurePath1 = URI.create("src/feature1/example-first.feature");
URI featurePath2 = URI.create("src/feature1/example-second.feature");
Feature resource1 = createResourceMock(featurePath1);
Feature resource2 = createResourceMock(featurePath2);
builder.addUnique(resource1);
builder.addUnique(resource2);
List<Feature> features = builder.build();
assertAll(() -> assertThat(features.size(), equalTo(2)), () -> assertThat(features.get(0).getUri(), equalTo(featurePath1)), () -> assertThat(features.get(1).getUri(), equalTo(featurePath2)));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class JsonFormatterTest method should_format_scenario_with_a_rule.
@Test
void should_format_scenario_with_a_rule() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: Banana party\n" + "\n" + " Rule: This is all monkey business\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(new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()"))).build().run();
String expected = "" + "[\n" + " {\n" + " \"line\": 1,\n" + " \"elements\": [\n" + " {\n" + " \"start_timestamp\": \"1970-01-01T00:00:00.000Z\",\n" + " \"line\": 4,\n" + " \"name\": \"Monkey eats bananas\",\n" + " \"description\": \"\",\n" + " \"id\": \";monkey-eats-bananas\",\n" + " \"type\": \"scenario\",\n" + " \"keyword\": \"Scenario\",\n" + " \"steps\": [\n" + " {\n" + " \"result\": {\n" + " \"duration\": 1000000,\n" + " \"status\": \"passed\"\n" + " },\n" + " \"line\": 5,\n" + " \"name\": \"there are bananas\",\n" + " \"match\": {\n" + " \"location\": \"StepDefs.there_are_bananas()\"\n" + " },\n" + " \"keyword\": \"Given \"\n" + " }\n" + " ]\n" + " }\n" + " ],\n" + " \"name\": \"Banana party\",\n" + " \"description\": \"\",\n" + " \"id\": \"banana-party\",\n" + " \"keyword\": \"Feature\",\n" + " \"uri\": \"file:path/test.feature\",\n" + " \"tags\": []\n" + " }\n" + "]";
assertJsonEquals(expected, out);
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class JsonFormatterTest method should_handle_write_from_a_hook.
@Test
void should_handle_write_from_a_hook() {
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()", testCaseState -> testCaseState.log("printed from hook"))), singletonList(new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()")), emptyList())).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" + " \"output\": [\n" + " \"printed from hook\"\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" + " }\n" + " ],\n" + " \"tags\": []\n" + " }\n" + "]";
assertJsonEquals(expected, out);
}
Aggregations