【发布时间】:2018-09-01 22:24:00
【问题描述】:
我正在尝试模拟下面的休息电话
restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<User>(user), void.class);
这里是 JUNIT
Mockito.when(restTemplate.exchange(Matchers.any(), Matchers.eq(HttpMethod.PUT), Matchers.any(HttpEntity.class), Matchers.eq(Void.class))).thenReturn(new ResponseEntity<>(HttpStatus.ACCEPTED));
但问题是当我调试代码时。即使我从模拟中抛出异常,它也总是返回 NULL。
我不确定我在这里做错了什么
【问题讨论】:
标签: java spring rest junit mockito