외부 api (1) 썸네일형 리스트형 RestClientTest를 알아보자~ RestClientTest 어노테이션은 외부 API를 사용할 때 대상 API를 MOCKING 할 수 있는 유용한 테스트이다. 요청을 받는 쪽이 아닌 요청을 하는 쪽 입장에서의 테스트이다. @RestClientTest를 사용하면 MockRestServiceServer라는 임시 서버를 Bean으로 생성해준다. @SpringBootTest와 달리 지정한 최소한의 Context만 사용해서 테스트를 진행한다. 아래는 기존 Service 코드이다. @Service public class RestClientTestService { private final RestTemplate restTemplate; private final String openApiUrl = "https://httpbin.org/get"; pub.. 이전 1 다음