@RunWith(MockitoJUnitRunner.class)
public class TestMail{
@Autowired(required = true)
SomeFactory someFactory;
private @Mock MailService mailService;
private @Captor ArgumentCaptor<List<MailList>> mailListCaptor;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@PostConstruct
public void init() throws Exception {
logger.info("someFactory {}", someFactory);
}
}
This is sample code. Before using mockito or the @Beofre annotation everything seems to be fine. Now its mocking the objects correctly but someFactory is not autowired correctly.
Before Mockito everything worked fine.