android之单元测试问题汇总

问题1:

Can't create handler inside thread that has not called Looper.prepare()

解决1:

 Looper.prepare();


问题2:

getMainLooper()' on a null object reference

解决2:

 Looper.getMainLooper()

问题3:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
解决3:
对这种情况一定要先判断是否为空,如果不为空再做强转
Integer tmp;
...
if(tmp) != null) {
    setValue(tmp.intValue());
}

问题4:Actually, there were zero interactions with this mock.
 
 

猜你喜欢

转载自blog.csdn.net/hqyhqyhq/article/details/78581329
今日推荐