java
runtime_error
ai_generated
true
org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers! 0 matchers expected, 1 recorded
ID: java/mockito-wrong-type-argument
80%Fix Rate
86%Confidence
0Evidence
2024-06-12First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8+ | active | — | — | — |
Root Cause
Mixing matchers and exact values in same method call, or using matchers outside of when/verify.
generic中文
在同一方法调用中混合使用匹配器和精确值,或在 when/verify 之外使用匹配器。
Workarounds
-
95% success Use matchers for all parameters consistently
when(mock.method(anyString(), anyInt())).thenReturn(value);
-
90% success Use eq() for exact values with matchers
when(mock.method(eq("exact"), anyInt())).thenReturn(value);
Dead Ends
Common approaches that don't work:
-
Using any() for all parameters
50% fail
May cause UnnecessaryStubbingException if not all used.
-
Removing matchers and using exact values only
40% fail
Reduces test flexibility; may not match actual calls.