use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class TestCaseStateTest method provides_both_the_example_row_line_and_scenario_outline_line_for_scenarios_from_scenario_outlines.
@Test
void provides_both_the_example_row_line_and_scenario_outline_line_for_scenarios_from_scenario_outlines() {
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario Outline: Test scenario\n" + " Given I have 4 <thing> in my belly\n" + " Examples:\n" + " | thing | \n" + " | cuke | \n");
TestCaseState state = createTestCaseState(feature);
assertThat(state.getLine(), is(6));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class TestCaseStateTest method provides_the_uri_and_scenario_line_as_unique_id.
@Test
void provides_the_uri_and_scenario_line_as_unique_id() {
Feature feature = TestFeatureParser.parse("file:path/file.feature", "" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have 4 cukes in my belly\n");
TestCaseState state = createTestCaseState(feature);
assertThat(state.getUri() + ":" + state.getLine(), is(new File("path/file.feature:2").toURI().toString()));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class AmbiguousStepDefinitionsExceptionTest method can_report_ambiguous_step_definitions.
@Test
void can_report_ambiguous_step_definitions() {
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have 4 cukes in my belly\n");
Step mockPickleStep = feature.getPickles().get(0).getSteps().get(0);
PickleStepDefinitionMatch mockPickleStepDefinitionMatchOne = mock(PickleStepDefinitionMatch.class);
when(mockPickleStepDefinitionMatchOne.getPattern()).thenReturn("PickleStepDefinitionMatchOne_Pattern");
when(mockPickleStepDefinitionMatchOne.getLocation()).thenReturn("PickleStepDefinitionMatchOne_Location");
PickleStepDefinitionMatch mockPickleStepDefinitionMatchTwo = mock(PickleStepDefinitionMatch.class);
when(mockPickleStepDefinitionMatchTwo.getPattern()).thenReturn("PickleStepDefinitionMatchTwo_Pattern");
when(mockPickleStepDefinitionMatchTwo.getLocation()).thenReturn("PickleStepDefinitionMatchTwo_Location");
List<PickleStepDefinitionMatch> matches = asList(mockPickleStepDefinitionMatchOne, mockPickleStepDefinitionMatchTwo);
AmbiguousStepDefinitionsException expectedThrown = new AmbiguousStepDefinitionsException(mockPickleStep, matches);
assertAll(() -> assertThat(expectedThrown.getMessage(), is(equalTo("" + "\"I have 4 cukes in my belly\" matches more than one step definition:\n" + " \"PickleStepDefinitionMatchOne_Pattern\" in PickleStepDefinitionMatchOne_Location\n" + " \"PickleStepDefinitionMatchTwo_Pattern\" in PickleStepDefinitionMatchTwo_Location"))), () -> assertThat(expectedThrown.getCause(), is(nullValue())), () -> assertThat(expectedThrown.getMatches(), is(equalTo(matches))));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method should_apply_identity_transform_to_data_table_when_target_type_is_object.
@Test
void should_apply_identity_transform_to_data_table_when_target_type_is_object() {
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have some step\n" + " | content |\n");
StepDefinition stepDefinition = new StubStepDefinition("I have some step", Object.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
CoreStepDefinition coreStepDefinition = new CoreStepDefinition(id, stepDefinition, expression);
List<Argument> arguments = coreStepDefinition.matchedArguments(feature.getPickles().get(0).getSteps().get(0));
assertThat(arguments.get(0).getValue(), is(equalTo(DataTable.create(singletonList(singletonList("content"))))));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method should_convert_empty_pickle_table_cells_to_null_values.
@Test
void should_convert_empty_pickle_table_cells_to_null_values() {
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have some step\n" + " | |\n");
StepDefinition stepDefinition = new StubStepDefinition("I have some step", Object.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
CoreStepDefinition coreStepDefinition = new CoreStepDefinition(id, stepDefinition, expression);
List<Argument> arguments = coreStepDefinition.matchedArguments(feature.getPickles().get(0).getSteps().get(0));
assertEquals(DataTable.create(singletonList(singletonList(null))), arguments.get(0).getValue());
}
Aggregations