Mockito

Mock Activiti TaskService, TaskQuery, NativeTaskQuery in Junit

In this tutorial we will how to mock Activiti TaskService, TaskQuery, NativeTaskQuery in Junit test class. Suppose you have Spring service class where you are doing some business flow for your application. So you are using activiti’s TaskService to create list of activiti Tasks using the method createNativeTaskQuery(). You may need to create also TaskQuery […]

Mock ObjectMapper.readValue() using Junit Mockito

Introduction This example will show you how to mock ObjectMapper.readValue() using Junit Mockito. When we write Junit test cases or classes, we generally do not test on real object that are injected into the class that has to be tested using Junit to avoid any test case failure at some point, instead we want to […]

Mock an Autowired @Value field in Spring with Junit Mockito

Introduction The below example will show you how to mock an Autowired @Value field in Spring with Junit Mockito. Generally we read some configuration values from properties file into Spring bean or component class using @Value annotated attributes but when we want to test such service or component class using Junit test class then it […]

JUnit Mockito doNothing Example

In this post, I will be showing one of the most widely used and popular JUnit Testing Mocking framework – Mockito. Mockito is one of the widely used testing API for Java. Prerequisites The following configurations are required in order to run the application Eclipse JDK 1.7 Have maven installed and configured Junit, Mockito, PowerMockito […]

JUnit Mockito doReturn Example

In this post, I will be showing one of the most widely used and popular JUnit Testing Mocking framework – Mockito. Mockito is one of the widely used testing API for Java. Prerequisites The following configurations are required in order to run the application Eclipse JDK 1.7 Have maven installed and configured Junit, Mockito, PowerMockito […]

Scroll to top