Injection an object though InjectMocks Spy

Viewed 3433

I need to run series of unit tests over a class, which has a @Autowired Logger implementation. The base idea of realization was:

@Mock Logger logger;
@InjectMocks
TestedClass tested;

but i want to save the logging output functionality.

Does Mockito lib allow to inject objects with @InjectMock? I'w seen examples of @Spy annotation, but when i tried to use it, i always got NullPointerException. I know that i can always directly use reflect, but the idea is to avoid such code.

1 Answers
Related