use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class MethodFormat method format.
String format(Method method) {
String signature = method.toGenericString();
Matcher matcher = METHOD_PATTERN.matcher(signature);
if (matcher.find()) {
String qc = matcher.group(3);
String m = matcher.group(4);
String qa = matcher.group(5);
return format.format(new Object[] { qc, m, qa });
} else {
throw new CucumberBackendException("Cucumber bug: Couldn't format " + signature);
}
}
use of io.cucumber.core.backend.CucumberBackendException 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)")));
}
use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class Java8LambdaStepDefinitionTest method should_fail_for_param_with_generic_list.
@Test
void should_fail_for_param_with_generic_list() {
StepDefinitionBody.A1<List<String>> body = p1 -> {
};
Java8StepDefinition stepDefinition = Java8StepDefinition.create("some step", StepDefinitionBody.A1.class, body);
Executable testMethod = () -> stepDefinition.parameterInfos().get(0).getTypeResolver().resolve();
CucumberBackendException actualThrown = assertThrows(CucumberBackendException.class, testMethod);
assertThat("Unexpected exception message", actualThrown.getMessage(), is(equalTo("Can't use java.util.List in lambda step definition \"some step\". " + "Declare a DataTable or DocString argument instead and convert " + "manually with 'asList/asLists/asMap/asMaps' and 'convert' respectively")));
}
use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class Java8LambdaStepDefinitionTest method should_fail_for_param_with_non_generic_list.
@Test
void should_fail_for_param_with_non_generic_list() {
StepDefinitionBody.A1<List> body = p1 -> {
};
Java8StepDefinition stepDefinition = Java8StepDefinition.create("some step", StepDefinitionBody.A1.class, body);
Executable testMethod = () -> stepDefinition.parameterInfos().get(0).getTypeResolver().resolve();
CucumberBackendException actualThrown = assertThrows(CucumberBackendException.class, testMethod);
assertThat("Unexpected exception message", actualThrown.getMessage(), is(equalTo("Can't use java.util.List in lambda step definition \"some step\". " + "Declare a DataTable or DocString argument instead and convert " + "manually with 'asList/asLists/asMap/asMaps' and 'convert' respectively")));
}
use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class OpenEJBObjectFactory method getInstance.
@Override
public <T> T getInstance(Class<T> type) {
if (instances.containsKey(type)) {
return type.cast(instances.get(type));
}
T object;
try {
object = type.newInstance();
container.getContext().bind("inject", object);
} catch (Exception e) {
throw new CucumberBackendException("can't create " + type.getName(), e);
}
instances.put(type, object);
return object;
}
Aggregations