use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class JavaStepDefinitionTransposeTest method isTransposed.
private boolean isTransposed(Method method) {
Steps steps = new Steps();
Lookup lookup = new SingletonFactory(steps);
StepDefinition stepDefinition = new JavaStepDefinition(method, "some text", lookup);
return stepDefinition.parameterInfos().get(0).isTransposed();
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method table_expression_with_type_creates_table_from_table.
@Test
void table_expression_with_type_creates_table_from_table() {
StepDefinition stepDefinition = new StubStepDefinition("Given some stuff:", DataTable.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
List<Argument> match = expression.match("Given some stuff:", table);
DataTable dataTable = (DataTable) match.get(0).getValue();
assertThat(dataTable.cells(), is(equalTo(table)));
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method docstring_expression_transform_doc_string_to_json_node.
@Test
void docstring_expression_transform_doc_string_to_json_node() {
String docString = "{\"hello\": \"world\"}";
String contentType = "json";
registry.defineDocStringType(new DocStringType(JsonNode.class, contentType, (String s) -> objectMapper.convertValue(docString, JsonNode.class)));
StepDefinition stepDefinition = new StubStepDefinition("Given some stuff:", JsonNode.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
List<Argument> match = expression.match("Given some stuff:", docString, contentType);
JsonNode node = (JsonNode) match.get(0).getValue();
assertThat(node.asText(), equalTo(docString));
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method docstring_expression_transform_doc_string_to_string.
@Test
void docstring_expression_transform_doc_string_to_string() {
String docString = "A rather long and boring string of documentation";
StepDefinition stepDefinition = new StubStepDefinition("Given some stuff:", String.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
List<Argument> match = expression.match("Given some stuff:", docString, null);
assertThat(match.get(0).getValue(), is(equalTo(docString)));
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class StepDefinitionMatchTest method throws_could_not_invoke_step_when_execution_failed_with_null_arguments.
@Test
void throws_could_not_invoke_step_when_execution_failed_with_null_arguments() {
Feature feature = TestFeatureParser.parse("file:test.feature", "" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have an null value\n");
Step step = feature.getPickles().get(0).getSteps().get(0);
StepDefinition stepDefinition = new StubStepDefinition("I have an {word} value", new CucumberBackendException("This exception is expected!", new IllegalAccessException()), String.class);
List<Argument> arguments = asList(() -> null);
StepDefinitionMatch stepDefinitionMatch = new PickleStepDefinitionMatch(arguments, stepDefinition, URI.create("file:path/to.feature"), step);
Executable testMethod = () -> stepDefinitionMatch.runStep(null);
CucumberException actualThrown = assertThrows(CucumberException.class, testMethod);
assertThat("Unexpected exception message", actualThrown.getMessage(), is(equalTo("Could not invoke step [I have an {word} value] defined at '{stubbed location with details}'.\n" + "It appears there was a problem with the step definition.\n" + "The converted arguments types were (null)")));
}
Aggregations