I\'m using Mockito\'s @Mock and @InjectMocks annotations to inject dependencies into private fields which are annotated with Spring\'s @Autow
@Mock
@InjectMocks
@Autow
In Spring there is a dedicated utility called ReflectionTestUtils for this purpose. Take the specific instance and inject into the the field.
ReflectionTestUtils
@Spy .. @Mock .. @InjectMock Foo foo; @BeforeEach void _before(){ ReflectionTestUtils.setField(foo,"bar", new BarImpl());// `bar` is private field }