【发布时间】:2020-07-17 13:08:54
【问题描述】:
我正在编写一个单元测试,它访问 App 类中 LinkedHashMap 的公共变量。我想模拟这个返回空列表,请问我该怎么做
App 有这个变量
public LinkedHashMap<String, ArrayList<QCCheck>> mapOfQCC =
new LinkedHashMap<>();
单元测试需要mapOfQCC返回空列表
我试过了,没用
every(app.mapOfQCC).thenReturn(LinkedHashMap<String, ArrayList<QCCheck>>())
错误
when() requires an argument which has to be 'a method call on a mock'.
For example:
when(mock.getArticles()).thenReturn(articles);
提前致谢 回复
【问题讨论】:
标签: java android unit-testing mockito