Method method = PowerMockito.method(CategoryController.class, "getCategory",List.class);//创建调用CategoryController类中的getCategory私有方法的method对象,参数是list对象
List<Category> category_all_actual = (List<Category>)method.invoke(categoryController, categories);//调用categoryController的私有方法,返回list对象,参数是list对象
assertArrayEquals(category_all_expect.toArray(), category_all_actual.toArray());//比较实际返回的对象与期望的对象是否相等.

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

或者:model).thenReturn(index_expect); // Mock私有方法

 

相关文章:

  • 2021-08-07
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-06-26
  • 2021-08-10
相关资源
相似解决方案