Mockito is used to test the execution of overloaded methods.
I'm attempting to have Mockito validate a call to a library function whose code cannot be altered; otherwise, the signature of varargs would have changed to publish(Record record, Record... records). publish(Record record) publish(Record... records) To test the execution of the second function, use the code below. verify(publisher).publish(ArgumentMatchers.<Record>any()); However, the preceding call always tries to check for a publish call with the NonArgs function and fails. Any ideas on how to make Mockito check for the var args function? For this test, I used mockito 3.11.2. As I looked around, I came across this lesson from here (https://www.scaler.com/topics/marker-interface-in-java/) that featured a similar example that advised selecting the correct overload when using the check function. Furthermore, it states that any() implements VarargMatcher - a specific marker interface, implying that this matcher can be used repeatedly.