Injecting Test Doubles in Spring using Mockito and BeanPostProcessors

I’m pretty sure that if you have ever used Spring and are familliar with unit testing, you have encountered a problem related to injecting mocks / spies (Test Doubles) in the Spring’s application context which you wouldn’t want to modify. This article presents an approach how to solve this issue using Spring’s components.

Project structure

 
Let’s start with the project structure:
 
 
Project structure
As usual to present a problem I’m trying to show a very simple project structure. The approach that I’m about to show could show more benefits if I made the problem more extensive as we had in our project:


Source : http://www.javacodegeeks.com/2013/08/injecting-test-doubles-in-spring-using-mockito-and-beanpostprocessors.html

Back to Top