org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'
异常原因:
1.mockito的jar包中缺少方法
2.mock方法的时候,返回的是对象,而对象没有重写equals方法
3.mock的实例方法调用方法错误
解决方法:
1.用powermock中的api解决问题,在类中添加:@RunWith(PowerMockRunner.class)
2.如果是第二种情况,则需要重写返回对象的equals方法
3.
把A a = new A();
PowerMockito.when(a.getTemplate()).thenReturn(template);
改成:
@Mock
private A a= spy(new A());
PowerMockito.when(a.getTemplate()).thenReturn(template);
org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'的更多相关文章
- org.mockito.exceptions.misusing.CannotStubVoidMethodWithReturnValue
错误原因:mock的时候,不能mock重载的方法 解决方法:直接mock它的父类的方法 org.mockito.exceptions.misusing.CannotStubVoidMethodWith ...
- docker: "build" requires 1 argument. See 'docker build --help'.
http://bbs.csdn.net/topics/391040030 docker build --tag="ouruser/sinatra:v3" -<Dockerf ...
- 基于spring-boot的应用程序的单元+集成测试方案
目录 概述 概念解析 单元测试和集成测试 Mock和Stub 技术实现 单元测试 测试常规的bean 测试Controller 测试持久层 集成测试 从Controller开始测试 从中间层开始测试 ...
- Mockito: InvalidUseOfMatchersException
异常报错信息: org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument match ...
- This exception may occur if matchers are combined with raw values
org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers!3 ma ...
- JUnit + Mockito 单元测试(二)(good)
import org.junit.Test; import org.mockito.Matchers; import org.mockito.Mockito; import java.util.Lis ...
- Mockito常用方法及示例
Mockit是一个开源mock框架,官网:http://mockito.org/,源码:https://github.com/mockito/mockito 要使用Mockit,首先需要在我们工程中引 ...
- Powermockito 针对方法中new 对象的模拟,以及属性中new 对象的模拟
PowerMocker 是一个功能逆天的mock 工具. 一,Powermockito 针对方法中new 对象的模拟 // 如何才能mock掉 WeChatConfigUtil 这个类,让 weCha ...
- Mockito文档-单元测试技术
Overview Package Class Use Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES ...
随机推荐
- Wannafly挑战赛4 A解方程【二分/set/hash求解方程】
https://www.nowcoder.com/acm/contest/35/A 题目描述 给出n个整数和x,请问这n个整数中是否存在三个数a,b,c使得ax2+bx+c=0,数字可以重复使用. 输 ...
- rpm安装、卸载、升级、查询和验证
RPM 的全称为Redhat Package Manager ,是由Redhat 公司提出的,用于管理Linux 下软件包的软件.Linux 安装时,除了几个核心模块以外,其余几乎所有的模块均通过RP ...
- Android之9图的制作
.9.PNG确实是标准的PNG格式,只是在最外面一圈额外增加1px的边框,这个1px的边框就是用来定义图片中可扩展的和静态不变的区域.特别说明,left和top边框中交叉部分是可拉伸部分,未选中部分是 ...
- u-boot-2010.3移植到Tiny6410问题总结
问题1: u-boot-2010.3中nand_spl文件夹的作用:实现从Nandflash启动在编译是会建立几个链接文件,用这几个链接文件生成u-boot-spl-16k.bin nand_spl/ ...
- 开始使用 Docker (Linux 上运行 SQL Server) 上的 SQL Server 容器 - SQL Server | Microsoft Docs
原文:开始使用 Docker (Linux 上运行 SQL Server) 上的 SQL Server 容器 - SQL Server | Microsoft Docs 快速入门:使用 Docker ...
- How to create an IPA (Xcode 5)
This tutorial will walk you through the easiest way to generate an IPA using Xcode 5. We will be usi ...
- 【Linux】CentOS7上安装JDK 和卸载 JDK 【rpm命令的使用】
之前有过一篇在CentOS7上安装JDK的文章:http://www.cnblogs.com/sxdcgaq8080/p/7492426.html 在这里又说一次,是要使用rpm命令安装JDK的rpm ...
- 安装dcm4chee-arc-light-5.4.1-mysql步骤
一.进入网址: https://github.com/dcm4che/dcm4chee-arc-light/wiki/Installation 这个是GitHub上面给的步骤,可能会比较难理解,按照所 ...
- iOS常用第三方库大全,史上最全第三方库收集
下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UITableVie ...
- mipmap一
讲一下mipmap 生成的时候 指定texture 的mipmaplevel 8 然后memory自动就会那么大的 画的时候要在lineraspace(因为我是gpucopy所以不涉及这个问题 可能) ...