use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class StepDefinitionMatchTest method rethrows_target_invocation_exceptions_from_parameter_type.
@Test
void rethrows_target_invocation_exceptions_from_parameter_type() {
RuntimeException userException = new RuntimeException();
stepTypeRegistry.defineParameterType(new ParameterType<>("itemQuantity", "(few|some|lots of) (cukes|gherkins)", ItemQuantity.class, (String[] s) -> {
throw new CucumberInvocationTargetException(stubbedLocation, new InvocationTargetException(userException));
}));
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given I have some cukes in my belly\n");
Step step = feature.getPickles().get(0).getSteps().get(0);
StepDefinition stepDefinition = new StubStepDefinition("I have {itemQuantity} in my belly", ItemQuantity.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
CoreStepDefinition coreStepDefinition = new CoreStepDefinition(id, stepDefinition, expression);
List<Argument> arguments = coreStepDefinition.matchedArguments(step);
StepDefinitionMatch stepDefinitionMatch = new PickleStepDefinitionMatch(arguments, stepDefinition, null, step);
Executable testMethod = () -> stepDefinitionMatch.runStep(null);
RuntimeException actualThrown = assertThrows(RuntimeException.class, testMethod);
assertThat(actualThrown, sameInstance(userException));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method transforms_to_map_of_double_to_double.
@Test
void transforms_to_map_of_double_to_double() throws Throwable {
Method m = Steps.class.getMethod("mapOfDoubleToDouble", Map.class);
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given some text\n" + " | 100.5 | 99.5 | \n" + " | 0.5 | -0.5 | \n" + " | 1000 | 999 | \n");
Map<Double, Double> stepDefs = runStepDef(m, false, feature);
assertAll(() -> assertThat(stepDefs, hasEntry(1000.0, 999.0)), () -> assertThat(stepDefs, hasEntry(0.5, -0.5)), () -> assertThat(stepDefs, hasEntry(100.5, 99.5)));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method transforms_to_list_of_single_values_transposed.
@Test
void transforms_to_list_of_single_values_transposed() throws Throwable {
Method m = Steps.class.getMethod("listOfListOfDoubles", List.class);
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given some text\n" + " | 100.5 | 0.5 | 1000| \n" + " | 99.5 | -0.5 | 999 | \n");
List<List<Double>> stepDefs = runStepDef(m, true, feature);
assertThat(stepDefs.toString(), is(equalTo("[[100.5, 99.5], [0.5, -0.5], [1000.0, 999.0]]")));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method passes_transposed_data_table.
@Test
void passes_transposed_data_table() throws Throwable {
Method m = Steps.class.getMethod("plainDataTable", DataTable.class);
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given some text\n" + " | Birth Date | \n" + " | 1957-05-10 | \n");
DataTable stepDefs = runStepDef(m, true, feature);
assertAll(() -> assertThat(stepDefs.cell(0, 0), is(equalTo("Birth Date"))), () -> assertThat(stepDefs.cell(0, 1), is(equalTo("1957-05-10"))));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class CoreStepDefinitionTest method transforms_transposed_to_map_of_double_to_double.
@Test
void transforms_transposed_to_map_of_double_to_double() throws Throwable {
Method m = Steps.class.getMethod("transposedMapOfDoubleToListOfDouble", Map.class);
Feature feature = TestFeatureParser.parse("" + "Feature: Test feature\n" + " Scenario: Test scenario\n" + " Given some text\n" + " | 100.5 | 99.5 | \n" + " | 0.5 | -0.5 | \n" + " | 1000 | 999 | \n");
Map<Double, List<Double>> stepDefs = runStepDef(m, true, feature);
assertThat(stepDefs, hasEntry(100.5, asList(0.5, 1000.0)));
}
Aggregations