public void appendMethodInfo(final StringBuilder buf) { appendMethodInfo(null, buf); }
@SuppressWarnings("unchecked") private <T> byte[] attemptScreenshot(StepImplementationNode node, RootNodeExecutionContext context) { return ProvidesScreenshot.class.isAssignableFrom(node.getTargetClass()) ? getScreenshot(context, (Class<? extends ProvidesScreenshot>) node.getTargetClass()) : null; }
if (node.getMethodArgs() != null && node.getMethodArgs().length > 0) { List<Object> evaluatedArgsList = new ArrayList<>(); for (Object o : node.getMethodArgs()) { node.setMethodArgs(evaluatedArgs); SubSteps.Step stepAnnotation = node.getTargetMethod().getAnnotation(SubSteps.Step.class); String rawSourceLine = stepAnnotation.value(); rawSourceLine = rawSourceLine.replaceFirst("\\([^\\)]*\\)", o.toString()); node.setLine(rawSourceLine); context.getMethodExecutor().executeMethod(node.getTargetClass(), node.getTargetMethod(), evaluatedArgs); context.setTestsHaveRun();
final StepImplementationNode stepImplementationNode = new StepImplementationNode( execImpl.getImplementedIn(), execImpl.getMethod(), tags, depth); stepImplementationNode.setLine(step.getParameterLine()); stepImplementationNode.setFileUri(step.getSource().getAbsolutePath()); stepImplementationNode.setLineNumber(step.getSourceLineNumber()); stepImplementationNode.setSourceLine(step.getLine()); stepImplementationNode.setParameterNames(step.getParamNames());
@Override protected boolean execute(StepImplementationNode node, RootNodeExecutionContext context) { boolean success = false; try { context.getMethodExecutor().executeMethod(node.getTargetClass(), node.getTargetMethod(), node.getMethodArgs()); context.setTestsHaveRun(); success = true; } catch (final InvocationTargetException e) { addFailure(node, context, e.getTargetException()); } catch (final Throwable t) { addFailure(node, context, t); } return success; }
final StepImplementationNode stepImplementationNode = new StepImplementationNode( execImpl.getImplementedIn(), execImpl.getMethod(), tags, depth); stepImplementationNode.setLine(step.getParameterLine()); stepImplementationNode.setFileUri(step.getSource().getAbsolutePath()); stepImplementationNode.setLineNumber(step.getSourceLineNumber());
private Object[] getStepMethodArguments(final String stepParameter, final Map<String, String> parentArguments, final String stepImplementationPattern, final List<Map<String, String>> inlineTable, final Class<?>[] parameterTypes, final Class<? extends Converter<?>>[] converterTypes, final StepImplementationNode stepNode) { // does the stepParameter contain any <> which require substitution ? log.debug("getStepMethodArguments for: " + stepParameter); final String substitutedStepParam = substitutePlaceholders(stepParameter, parentArguments); stepNode.setLine(substitutedStepParam); List<Object> argsList = Util.getArgs(stepImplementationPattern, substitutedStepParam, parameterTypes, converterTypes); if (inlineTable != null) { if (argsList == null) { argsList = new ArrayList<Object>(); } argsList.add(inlineTable); } Object[] arguments = null; if (argsList != null) { arguments = new Object[argsList.size()]; arguments = argsList.toArray(arguments); } stepNode.setMethodArgs(arguments); return arguments; }
public void appendMethodInfo(final String prefix, final StringBuilder buf) { if (this.targetClass != null && this.targetMethod != null) { if (prefix != null) { buf.append(prefix); } buf.append(targetClass.getSimpleName()).append(".").append(targetMethod.getName()).append("("); if (this.getMethodArgs() != null) { boolean commaRequired = false; for (final Object arg : this.getMethodArgs()) { if (commaRequired) { buf.append(", "); } boolean quotes = false; if (arg instanceof String) { quotes = true; buf.append("\""); } buf.append(arg.toString()); if (quotes) { buf.append("\""); } commaRequired = true; } } buf.append(")").append("\n"); } }
private static Object[] getStepMethodArguments(final String stepParameter, final Map<String, String> parentArguments, final String stepImplementationPattern, final List<Map<String, String>> inlineTable, final Class<?>[] parameterTypes, final Class<? extends Converter<?>>[] converterTypes, final StepImplementationNode stepNode) { // does the stepParameter contain any <> which require substitution ? log.debug("getStepMethodArguments for: " + stepParameter); final String substitutedStepParam = substitutePlaceholders(stepParameter, parentArguments); stepNode.setLine(substitutedStepParam); List<Object> argsList = Arguments.getArgs(stepImplementationPattern, substitutedStepParam, parameterTypes, converterTypes, Configuration.INSTANCE.getConfig()); if (inlineTable != null) { if (argsList == null) { argsList = new ArrayList<Object>(); } argsList.add(inlineTable); } Object[] arguments = null; if (argsList != null) { arguments = new Object[argsList.size()]; arguments = argsList.toArray(arguments); if (arguments.length != parameterTypes.length) { throw new IllegalArgumentException( "Argument mismatch between what expected for step impl and what found in feature"); } } stepNode.setMethodArgs(arguments); return arguments; }
@SuppressWarnings("unchecked") private <T> byte[] attemptScreenshot(StepImplementationNode node, RootNodeExecutionContext context) { return ProvidesScreenshot.class.isAssignableFrom(node.getTargetClass()) ? getScreenshot(context, (Class<? extends ProvidesScreenshot>) node.getTargetClass()) : null; }
private String createMethodInfo(StepImplementationNode node) { final StringBuilder methodInfoBuffer = new StringBuilder(); node.appendMethodInfo(methodInfoBuffer); String methodInfo = methodInfoBuffer.toString(); if (methodInfo.contains("\"")) { methodInfo = methodInfo.replace("\"", "\\\""); } return replaceNewLines(methodInfo); }