Mockito error not applicable for arguments (void)

Mockito throws the error "The method when(T) in the type Stubber is not applicable for the arguments (void)" for the class I’m mocking, I can’t understand why.

code in question:

 Mockito.when(mockObject.myMethod(Mockito.any(MyExecutionContext.class))).thenReturn(value); 

I know that similar questions have been asked, but if someone can explain this decision or point me in the right direction, I would really appreciate it

+7
java mockito mocking
source share
1 answer

Decision:

 Mockito.doReturn(value) .when(mockObject) .myMethod(Mockito.any(MyExecutionContextβ€Œβ€‹.class)) 
+22
source share

All Articles