use of io.cucumber.core.backend.ParameterInfo in project cucumber-jvm by cucumber.
the class JavaParameterInfo method fromMethod.
static List<ParameterInfo> fromMethod(Method method) {
List<ParameterInfo> result = new ArrayList<>();
Type[] genericParameterTypes = method.getGenericParameterTypes();
Annotation[][] annotations = method.getParameterAnnotations();
for (int i = 0; i < genericParameterTypes.length; i++) {
boolean transposed = false;
for (Annotation annotation : annotations[i]) {
if (annotation instanceof Transpose) {
transposed = ((Transpose) annotation).value();
}
}
result.add(new JavaParameterInfo(genericParameterTypes[i], transposed));
}
return result;
}
use of io.cucumber.core.backend.ParameterInfo in project cucumber-jvm by cucumber.
the class PickleStepDefinitionMatch method runStep.
@Override
public void runStep(TestCaseState state) throws Throwable {
List<Argument> arguments = getArguments();
List<ParameterInfo> parameterInfos = stepDefinition.parameterInfos();
if (parameterInfos != null && arguments.size() != parameterInfos.size()) {
throw arityMismatch(parameterInfos.size());
}
List<Object> result = new ArrayList<>();
try {
for (Argument argument : arguments) {
result.add(argument.getValue());
}
} catch (UndefinedDataTableTypeException e) {
throw registerDataTableTypeInConfiguration(e);
} catch (CucumberExpressionException | CucumberDataTableException | CucumberDocStringException e) {
CucumberInvocationTargetException targetException;
if ((targetException = causedByCucumberInvocationTargetException(e)) != null) {
throw removeFrameworkFrames(targetException);
}
throw couldNotConvertArguments(e);
} catch (CucumberBackendException e) {
throw couldNotInvokeArgumentConversion(e);
} catch (CucumberInvocationTargetException e) {
throw removeFrameworkFrames(e);
}
try {
stepDefinition.execute(result.toArray(new Object[0]));
} catch (CucumberBackendException e) {
throw couldNotInvokeStep(e, result);
} catch (CucumberInvocationTargetException e) {
throw removeFrameworkFramesAndAppendStepLocation(e, getStepLocation());
}
}
use of io.cucumber.core.backend.ParameterInfo in project cucumber-jvm by cucumber.
the class StepExpressionFactory method createExpression.
public StepExpression createExpression(StepDefinition stepDefinition) {
List<ParameterInfo> parameterInfos = stepDefinition.parameterInfos();
if (parameterInfos.isEmpty()) {
return createExpression(stepDefinition.getPattern(), stepDefinitionDoesNotTakeAnyParameter(stepDefinition), false);
}
ParameterInfo parameterInfo = parameterInfos.get(parameterInfos.size() - 1);
return createExpression(stepDefinition.getPattern(), parameterInfo.getTypeResolver()::resolve, parameterInfo.isTransposed());
}
Aggregations