Top "Mockito" questions

Mockito is a mocking framework for Java.

PowerMockito mock single static method and return object

I want to mock a static method m1 from a class which contains 2 static methods, m1 and m2. And I …

java jakarta-ee mockito easymock powermock
Mockito: Trying to spy on method is calling the original method

I'm using Mockito 1.9.0. I want mock the behaviour for a single method of a class in a JUnit test, so …

java junit mockito
Can Mockito stub a method without regard to the argument?

I'm trying to test some legacy code, using Mockito. I want to stub a FooDao that is used in production …

java unit-testing mocking mockito
Usages of doThrow() doAnswer() doNothing() and doReturn() in mockito

I was learning mockito and I understood the basic usages of the above mentioned functions from the link. But I …

java mockito
Initialising mock objects - MockIto

There are many ways to initialize a mock object using MockIto. What is best way among these ? 1. public class SampleBaseTestCase { @…

java junit mockito
How to tell a Mockito mock object to return something different the next time it is called?

So, I'm creating a mock object as a static variable on the class level like so... In one test, I …

java unit-testing junit mocking mockito
Java verify void method calls n times with Mockito

I'm trying to verify that a (void) method is being called inside of a DAO - I'm using a commit …

java unit-testing junit mockito verify
Verify object attribute value with mockito

I have a method call which I want to mock with mockito. To start with I have created and injected …

java mocking mockito
Why doesn't Mockito mock static methods?

I read a few threads here about static methods, and I think I understand the problems misuse/excessive use of …

java methods static mockito
throw checked Exceptions from mocks with Mockito

I'm trying to have one of my mocked objects throw a checked Exception when a particular method is called. I'm …

java mocking mockito