You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a lambda or method reference expression as ArgumentMatcher and the matcher fails, the error message contains the lambda / method reference class name in "decamelized" form which is rather irritating, e.g.:
Expected would be that similar to anonymous classes the error output says "<custom argument matcher>". This could probably be achieved by testing for Class.isSynthetic() in org.mockito.internal.matchers.text.MatcherToString.toString(ArgumentMatcher<?>) before calling decamelizeMatcher there.
Test case
publicclassMockitoTest {
interfaceMyInterface {
voiddoSomething(Strings);
}
privatestaticbooleanmatches(Strings) {
returnfalse;
}
publicstaticvoidmain(String[] args) {
MyInterfacemock = mock(MyInterface.class);
try {
verify(mock).doSomething(argThat(arg -> false));
} catch (Errore) {
e.printStackTrace();
}
try {
verify(mock).doSomething(argThat(MockitoTest::matches));
} catch (Errore) {
e.printStackTrace();
}
// When an anonymous class is used the output is '<custom argument matcher>'// (as expected)verify(mock).doSomething(argThat(newArgumentMatcher<>() {
@Overridepublicbooleanmatches(Stringargument) {
returnfalse;
}
}));
}
}
The text was updated successfully, but these errors were encountered:
Version
Mockito version: 3.5.13
Description
Relates to #1932
When using a lambda or method reference expression as
ArgumentMatcher
and the matcher fails, the error message contains the lambda / method reference class name in "decamelized" form which is rather irritating, e.g.:Expected would be that similar to anonymous classes the error output says "<custom argument matcher>". This could probably be achieved by testing for
Class.isSynthetic()
inorg.mockito.internal.matchers.text.MatcherToString.toString(ArgumentMatcher<?>)
before callingdecamelizeMatcher
there.Test case
The text was updated successfully, but these errors were encountered: