Search code examples
javaspringspring-bootresttemplate

Does the new RestClient introduced in Spring Framework 6.1 have a variant suitable for testing like RestTemplate had with TestRestTemplate?


In spring framework 6.1, a new synchronous HTTP client RestClient was introduced. See also:

https://github.com/spring-projects/spring-framework/issues/29552

It aims to replace the existing RestTemplate.

In Spring Boot, there was a TestRestTemplate which could be used for integration tests. See also:

https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.utilities.test-rest-template

However, I could not find any mention of a variant for RestClient. What is the recommended way to do integration testing using RestClient ?


Solution

  • There's no test variant of RestClient. This Spring Framework issue is tracking a RestClient equivalent of WebClient's WebTestClient.