In this tutorial we are going to learn about mock unit testing. We are using here Mockito with Spring to write unit tests. We will also see how to mock an EJB session bean inside mocked service without constructor/setters injection. What is mocking Mocking is a technique to replace the actual implementation with some dummy or provided code chunk during unit testing. For example if we need to unit test some service which persist data to database then we can mock that persist method to add it to some in-memory collection. Also we can mock data retrieval to get the data from same collection or so. Mockito provide various class and features to implement the mocking seamlessly. Maven dependency We are using Spring (XML base configuration) and mockito for mock testing. Below dependencies are required. <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.9.RELEASE</ver...
Blogs about Java, J2ee, Multithreading, Data structure, Algorithm, Spring framework, Spring boot, Web services and open source technologies