【发布时间】:2017-10-24 07:19:29
【问题描述】:
我正在为获取映射编写单元测试,
@GetMapping("/abc/{Id}/def")
public String getAbc(@PathVariable String id, Model model) {
Map map = new HashMap();
map.put("abc", "abc1");
map.put("def", "def1");
model.addAllAttributes(map);
return "c/a/t";
}
如何验证模型部分,这给我编译错误,
verify(model, times(1)).addAllAttributes(map, argumentCaptor.capture());
我知道带有单个参数的模型可以通过以下方式验证:
verify(model, times(1)).addAttribute(eq("abc"),argumentCaptor.capture());
但我有带有地图作为参数的模型,任何帮助将不胜感激。 谢谢
【问题讨论】:
标签: spring spring-mvc junit mockito spring-test