use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method unknown_target_type_does_no_transform_data_table.
@Test
void unknown_target_type_does_no_transform_data_table() {
StepDefinition stepDefinition = new StubStepDefinition("Given some stuff:", UNKNOWN_TYPE);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
List<Argument> match = expression.match("Given some stuff:", table);
assertThat(match.get(0).getValue(), is(equalTo(DataTable.create(table))));
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method throws_for_unknown_parameter_types.
@Test
void throws_for_unknown_parameter_types() {
StepDefinition stepDefinition = new StubStepDefinition("Given a {unknownParameterType}");
List<Envelope> events = new ArrayList<>();
bus.registerHandlerFor(Envelope.class, events::add);
CucumberException exception = assertThrows(CucumberException.class, () -> stepExpressionFactory.createExpression(stepDefinition));
assertThat(exception.getMessage(), is("" + "Could not create a cucumber expression for 'Given a {unknownParameterType}'.\n" + "It appears you did not register a parameter type."));
assertThat(events, iterableWithSize(1));
assertNotNull(events.get(0).getUndefinedParameterType());
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method table_expression_with_type_creates_single_ingredients_from_table.
@Test
void table_expression_with_type_creates_single_ingredients_from_table() {
registry.defineDataTableType(new DataTableType(Ingredient.class, beanMapper(registry)));
StepDefinition stepDefinition = new StubStepDefinition("Given some stuff:", Ingredient.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
List<Argument> match = expression.match("Given some stuff:", tableTransposed);
Ingredient ingredient = (Ingredient) match.get(0).getValue();
assertThat(ingredient.name, is(equalTo("chocolate")));
}
use of io.cucumber.core.backend.StepDefinition 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.backend.StepDefinition 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