Top "Mockito" questions

Mockito is a mocking framework for Java.

How to capture a list of specific type with mockito

Is there a way to capture a list of specific type using mockitos ArgumentCaptore. This doesn't work: ArgumentCaptor<ArrayList&…

java unit-testing junit mockito
Example of Mockito's argumentCaptor

Can anyone please provide me an example showing how to use the org.mockito.ArgumentCaptor class and how it is …

java unit-testing junit mockito
Mockito matcher and array of primitives

With Mockito, I want to verify() a method call with byte[] in its argument list, but I didn't find how …

java mockito
Mockito: List Matchers with generics

Mockito offers: when(mock.process(Matchers.any(List.class))); How to avoid warning if process takes a List<Bar&…

java generics warnings mockito matcher
Mockito : doAnswer Vs thenReturn

I am using Mockito for service later unit testing. I am confused when to use doAnswer vs thenReturn. Can anyone …

java mockito
Unfinished Stubbing Detected in Mockito

I am getting following exception while running the tests. I am using Mockito for mocking. The hints mentioned by Mockito …

java mocking mockito
How do Mockito matchers work?

Mockito argument matchers (such as any, argThat, eq, same, and ArgumentCaptor.capture()) behave very differently from Hamcrest matchers. Mockito matchers …

java mocking mockito
Mockito: Inject real objects into private @Autowired fields

I'm using Mockito's @Mock and @InjectMocks annotations to inject dependencies into private fields which are annotated with Spring's @Autowired: @RunWith(…

java spring mockito
How to resolve Unneccessary Stubbing exception

My Code is as below, @RunWith(MockitoJUnitRunner.class) public class MyClass { private static final String code ="Test"; @Mock private MyClassDAO …

java junit mockito
when I run mockito test occurs WrongTypeOfReturnValue Exception

Error detail: org.mockito.exceptions.misusing.WrongTypeOfReturnValue: Boolean cannot be returned by updateItemAttributesByJuId() updateItemAttributesByJuId() should return ResultRich This exception might …

java mockito