Last active
August 29, 2015 14:16
-
-
Save regis-leray/05f7be67c88371aaaab1 to your computer and use it in GitHub Desktop.
Spring - Skip Nested dependency mock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MockPostProcessorAdapter extends InstantiationAwareBeanPostProcessorAdapter { | |
private static final MockUtil mockUtil = new MockUtil(); | |
public MockPostProcessorAdapter() { | |
super(); | |
} | |
@Override | |
public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { | |
return !mockUtil.isMock(bean); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had the same problem and I found another solution.
When Spring instantiate all your beans, it will check if it's a Mockito Mock and in this case, I return false for injection property. To use it, just inject it in a Spring context