Top "Mockito" questions

Mockito is a mocking framework for Java.

How to match null passed to parameter of Class<T> with Mockito

I have methods like these: public <T> method(String s, Class<T> t) {...} That I need …

java unit-testing mocking mockito
How to use MockMvcResultMatchers.jsonPath

MvcResult result = this.mockMvc.perform( MockMvcRequestBuilders.get(mockUrl)) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.content().contentType("application/ json;charset=UTF-8")) .…

java unit-testing mockito jsonpath
Mockito: How to easily stub a method without mocking all parameters

I have a method i'd like to stub but it has a lot of parameters. How can i avoid mocking …

java unit-testing mocking mockito stubbing
How to clean up mocks in spring tests when using Mockito

I'm pretty new to Mockito and have some trouble with clean up. I used to use JMock2 for unit tests. …

spring-mvc mockito spring-test
Mock class in class under test

How I can mock with Mockito other classes in my class which is under test? For example: MyClass.java class …

java unit-testing junit4 mockito robolectric
Mocking Apache HTTPClient using Mockito

I'm trying to mock Apache HttpClient Interface in order to mock one of its methods mentioned below to return a …

java mocking mockito apache-httpclient-4.x
Mock private static final field using mockito or Jmockit

I am using private static final LOGGER field in my class and I want LOGGER.isInfoEnabled() method to return false. …

java junit mockito static-members jmockit
Which Maven artifacts should I use to import PowerMock?

What jars do I need to add to my pom.xml to get PowerMock working with Mockito? I have the …

java maven mockito powermock
Comparison between Mockito vs JMockit - why is Mockito voted better than JMockit?

I'm investigating which mocking framework to use for my project and have narrowed it down to JMockit and Mockito. I …

java unit-testing mocking mockito jmockit
mock instance is null after @Mock annotation

I try to run this test: @Mock IRoutingObjHttpClient routingClientMock; @Mock IRoutingResponseRepository routingResponseRepositoryMock; @Test public void testSendRoutingRequest() throws Exception { CompleteRoutingResponse completeRoutingResponse = …

java unit-testing junit mocking mockito