【发布时间】:2019-10-17 07:27:08
【问题描述】:
我正在使用 Mockito 框架为现有的 spring-boot 项目编写测试用例。
在其中一个类中,他们在函数内部创建了 rest-template 的本地实例,而不是 @Autowiring。
public LatxDetails getLatxCaseDetail_Fallback(String endpoint, Map<String, String> requestMap) {
//some code
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.exchange(kxCreateEndpoint, HttpMethod.POST, httpEntity, String.class);
//some code
我无法模拟其余调用。我无法添加任何其他外部 jar 或更改代码。我应该如何进行?非常感谢任何帮助。
【问题讨论】:
标签: java spring-boot junit mockito spring-boot-test