|
28 | 28 | import java.lang.reflect.Parameter; |
29 | 29 | import java.util.HashMap; |
30 | 30 | import java.util.Map; |
| 31 | +import java.util.List; |
31 | 32 | import java.util.Objects; |
32 | 33 | import java.util.Optional; |
33 | 34 | import java.util.UUID; |
@@ -62,15 +63,20 @@ public void interceptTestTemplateMethod(final Invocation<Void> invocation, |
62 | 63 | private void sendParameterEvent(final ReflectiveInvocationContext<Method> invocationContext, |
63 | 64 | final ExtensionContext extensionContext) { |
64 | 65 | final Parameter[] parameters = invocationContext.getExecutable().getParameters(); |
65 | | - for (int i = 0; i < parameters.length; i++) { |
66 | | - final Parameter parameter = parameters[i]; |
| 66 | + final List<Object> arguments = invocationContext.getArguments(); |
| 67 | + int argumentIndex = 0; |
67 | 68 |
|
| 69 | + for (final Parameter parameter : parameters) { |
68 | 70 | final Class<?> parameterType = parameter.getType(); |
69 | | - // Skip default jupiter injectables as TestInfo, TestReporter and TempDirectory |
70 | | - if (parameterType.getCanonicalName().startsWith("org.junit.jupiter.api")) { |
| 71 | + |
| 72 | + // Skip JUnit injectables AND synthetic parameters |
| 73 | + if (parameterType.getCanonicalName().startsWith("org.junit.jupiter.api") |
| 74 | + || parameter.isSynthetic() |
| 75 | + || argumentIndex >= arguments.size()) { |
71 | 76 | continue; |
72 | 77 | } |
73 | | - final Object value = invocationContext.getArguments().get(i); |
| 78 | + |
| 79 | + final Object value = arguments.get(argumentIndex++); |
74 | 80 | final Map<String, String> map = new HashMap<>(); |
75 | 81 | map.put(ALLURE_PARAMETER, parameter.getName()); |
76 | 82 | map.put(ALLURE_PARAMETER_VALUE_KEY, ObjectUtils.toString(value)); |
|
0 commit comments