Top "Mockito" questions

Mockito is a mocking framework for Java.

Mockito verify order / sequence of method calls

Is there a way to verify if a methodOne is called before methodTwo in Mockito? public class ServiceClassA { public void …

java unit-testing mockito
@RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this)

While writing a new jUnit4 test, I'm wondering whether to use @RunWith(MockitoJUnitRunner.class) or MockitoAnnotations.initMocks(this). I created …

java junit4 mockito
Mockito Exception - when() requires an argument which has to be a method call on a mock

I have a very simple test case that is using Mockito and Spring Test framework. When I do when(pcUserService.…

java controller mockito spring-test
Mockito + PowerMock LinkageError while mocking system class

I've got such a code snippet: @RunWith(PowerMockRunner.class) @PrepareForTest({Thread.class}) public class AllMeasuresDataTest { @Before public void setUp() throws …

java mockito junit4 powermock linkageerror
Could not initialize plugin: interface org.mockito.plugins.MockMaker

I'm getting following exception once tests is started: Testcase: treeCtorArgumentTest(com.xythos.client.drive.cachedtree.CachedTreeTest): Caused an ERROR Could …

mockito
Mockito: Stubbing Methods That Return Type With Bounded Wild-Cards

Consider this code: public class DummyClass { public List<? extends Number> dummyMethod() { return new ArrayList<Integer>(); } } public …

java unit-testing generics mockito bounded-wildcard
Mockito - @Spy vs @Mock

Mockito - I understand a spy calls the real methods on an object, while a mock calls methods on the …

java unit-testing mocking mockito spy
How to verify multiple method calls with different params

I have the following method that I wish to verify behaviour on. public void methodToTest(Exception e, ActionErrors errors) { ... errors.…

java mockito
Mockito.any() pass Interface with Generics

is it possible to pass the type of an interface with generics? The interface: public interface AsyncCallback<T> …

java generics mockito
Using Mockito to mock a local variable of a method

I have a class A that needs to the tested. The following is the definition of A: public class A { …

java mocking mockito functional-testing