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私有方法


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。