I have a problem with mockito. I get a bizarre error that I cannot solve.
Error:
[error] Invalid use of argument matchers!
[error] 1 matchers expected, 3 recorded:
[error] -> at service.ServiceTest.test(ServiceTest.java:149)
[error] -> at service.ServiceTest.test(ServiceTest.java:149)
[error] -> at service.ServiceTest.test(ServiceTest.java:149)
and the test method that is next to this test method calls:
[error] Unfinished stubbing detected here:
[error] -> at service.ServiceTest.test(ServiceTest.java:149)
Method Code:
List<String> method(final Map<String, String> numbersMap, final Map<String, String> invalidNumbersMap, final String filename) {
}
protected List<User> run(Map<String, String> numbersMap, final String filename, final Map<String, String> invalidNumbersMap) {
List<String> processedUsedNumbers = method(numbersMap, invalidNumbersMap, filename);
return new ArrayList<>();
}
Test code (indicating this exception)
@Test
public void test() {
doReturn(new ArrayList<String>()).when(service).method(anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), anyString());
Map<String, String> inputMap = getExampleMap(3);
List<User> result = service.run(inputMap, "file.csv", new HashMap<>());
verify(service, times(1)).method(eq(inputMap), anyMapOf(String.class, String.class), eq("file.csv"));
}
Method of marking up the method:
when(service.method(anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), anyString())).thenReturn(new ArrayList<String>());
doesn't matter, and I still get the same exception from mockito.
I do not know what happened. Import looks great, options are also used, so when did I make a mistake? Is anyone
UPDATE / DECISION
Ok, I found the reason for this error. After changing the default access modification method to protect the entire test, it works fine. Now the method in the class looks like this:
protected List<String> method(final Map<String, String> numbersMap, final Map<String, String> invalidNumbersMap, final String filename) {
}
Mockito . .