org.mockito.exceptions.misusing.UnfinishedStubbingException
来源:互联网 发布:掌上电力显示网络问题 编辑:程序博客网 时间:2024/06/07 03:01
问题 org.mockito.exceptions.misusing.UnfinishedStubbingException:
当我们一个mock方法中继续mock的时候就会跑出异常。比如如下例子
when(bbbModel.getAAAModel()).thenReturn(AAATest.mocAAAModel())
关键是你在AAATest.mockAAAmodel()方法中继续mock 会的话 就会跑出异常,这与mock的实现机制有关系。(You're nesting mocking inside of mocking)
AAATest.mockAAAmodel(){
....
AAA aaa = mock(AAA.class);
when(aaa.getNames()).thenReturn(Lists.newArrayList("1","2","3","4"));
}
}
具体问题是mock搞不清楚你到底是在mock aaa.getNames()方法 还是 model.getAAAmodel()方法。
解决办法:
XXXmodel
AAAModel aaaModel = AAATest.mockAAAModel();when(bbbmodel.getAAAModel()).thenReturn(aaaModel);
0 0
- org.mockito.exceptions.misusing.UnfinishedStubbingException
- org.mockito.exceptions.misusing.UnfinishedStubbingException:
- org.apache.ibatis.exceptions.PersistenceException:
- org.apache.ibatis.exceptions.PersistenceException
- org.apache.ibatis.exceptions.TooManyResultsException:
- org.apache.ibatis.exceptions.PersistenceException
- org.apache.ibatis.exceptions.PersistenceException
- org.apache.ibatis.exceptions.PersistenceException: 问题
- MyBatis org.apache.ibatis.exceptions.PersistenceException NoSuchMethodException
- org.apache.ibatis.exceptions.PersistenceException:解决方法
- Mybatis-org.apache.ibatis.exceptions.PersistenceException
- 异常:org.apache.ibatis.exceptions.PersistenceException:
- org.apache.ibatis.exceptions.PersistenceException: 的解决
- Mockito
- mockito
- Mockito
- Mockito
- mockito
- SSH生命周期图
- Chronometer控件的使用
- Java 导出txt文件
- STC89S52RC模拟串口
- MAVEN搭建SpirngMVC和Spirng所需的依赖包
- org.mockito.exceptions.misusing.UnfinishedStubbingException
- ListCollectionView.Refresh issue
- 【keil配置,备查】STM32开发环境(工具)之Keil MDK 介绍
- Python中用eval将字符串转换为字典时候出错:NameError: name ‘null’ is not defined的解决方法
- IOS常用第三方框架 --- MBProgressHUD 提示效果
- ASCII编码和UNICODE编码转换
- Java开发环境搭建(一环境变量)
- Runtime之对象、类(类对象)、元类
- 电子商务文件存储及读取服务的设计和开发思路(JMagick用于生成高清的缩略图)