首页 > 代码库 > object is not an instance of declaring class

object is not an instance of declaring class

错误原因:invoke方法的时候,应该是类的实例对象,而不是类本身

解决方法:把

PowerMockito.doReturn(index_expect).when(IndexController.class, "processPage", pageCode, request, response,
model); // Mock私有方法

 改成:

PowerMockito.doReturn(index_expect).when(controller, "processPage", pageCode, request, response,
model); // Mock私有方法

object is not an instance of declaring class