问题描述
我的Service类中有@PostConstruct,我正在为此编写groovy测试用例。我已经在init()方法中嘲笑了该调用,但是它不起作用:
@Service
@Transactional
public class ServiceImpl implements Service{
private Dao testDao;
@Autowired
private AbcDao abcDao;
@PostConstruct
public void init() {
testDao = abcDao.findByName("testString");
Assert.notNull(testDao,"testDao not found");
}
public method toBeTest(){
}
}
我将groovy测试用例编写为:
public class ServiceSpec{
@Autowired
Service service
def 'Test method'() {
given:
Dao test=new Dao()
abcDao.findByName("testString") >> test
when:
service.toBeTest()
then:
true
}
}
But it doesn't work and fail in the Assert statement.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)