Skip to content

Commit 1ba0d86

Browse files
committed
Fixed TestUtils invoking wrong method when testing
1 parent d86f173 commit 1ba0d86

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

testing/src/main/java/it/angrybear/yagl/TestUtils.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void testMultipleMethods(final @NotNull Object executor, final @No
6262
}
6363

6464
/**
65-
* Allows to test the given <i>targetMethod</i>.
65+
* Allows testing the given <i>targetMethod</i>.
6666
* It verifies that the <i>executor</i> invokes <i>targetMethod</i> and that,
6767
* upon execution, <i>target</i> invokes <i>invokedMethod</i>.
6868
*
@@ -86,13 +86,16 @@ public static void testMultipleMethods(final @NotNull Object executor, final @No
8686
ReflectionUtils.setAccessible(targetMethod).invoke(executor, parameters);
8787

8888
// Verify execution with mock
89-
new Refl<>(verify(target)).invokeMethod(invokedMethod, invokedMethodParamTypes,
89+
Method method = target.getClass().getDeclaredMethod(invokedMethod, invokedMethodParamTypes);
90+
ReflectionUtils.setAccessible(method).invoke(verify(target),
9091
Arrays.stream(captors).map(ArgumentCaptor::capture).toArray(Object[]::new));
9192

9293
return captors;
9394
} catch (Exception e) {
9495
System.err.printf("An exception occurred while testing method '%s'%n", methodToString(targetMethod));
9596
System.err.printf("target: '%s'%n", target.getClass().getCanonicalName());
97+
System.err.printf("method: '%s'%n", ReflectionUtils.getMethod(target.getClass(), null, invokedMethod,
98+
invokedMethodParamTypes));
9699
System.err.printf("Invoked method parameter types: '%s'%n", Arrays.toString(invokedMethodParamTypes));
97100
System.err.printf("Captors: '%s'%n", Arrays.toString(captors));
98101
ExceptionUtils.throwException(e);

0 commit comments

Comments
 (0)