【发布时间】:2017-08-04 20:20:11
【问题描述】:
我的代码中只有参数化构造函数,我需要通过它进行注入。
我想监视参数化构造函数以注入模拟对象作为我的 junit 的依赖项。
public RegDao(){
//original object instantiation here
Notification ....
EntryService .....
}
public RegDao(Notification notification , EntryService entry) {
// initialize here
}
we have something like below :
RegDao dao = Mockito.spy(RegDao.class);
但是我们有什么东西可以让我在构造函数中注入模拟对象并监视它吗?
【问题讨论】: