title: TestRestTemplate vs WebTestClient vs RestAssured : What is the best approach for integration testing of Spring Boot Rest API
body: <p>Which of the 3 APIs: TestRestTemplate, WebTestClient, RestAssured  is the most efficient for integration testing of Spring Boot Rest API (non-reactive) with respect to the following:</p>
  
  <ol>
  <li>Ensures compatibility with Spring boot for incremental versions.</li>
  <li>Easy-to-use and extensive assertions for checking status codes, headers, both JSON/XML payload validation, response time, etc.</li>
  <li>Has the possibility to test spring container configuration.</li>
  <li>Features to reuse specific checks across all end points.</li>
  <li>Is the most stable and therefore an Industry common practice.</li>
  </ol>
  
  <p>Few initial findings which sort of prevent one of them to be marked as clear winner are:</p>
  
  <ul>
  <li><p>TestRestTemplate &amp; WebTestClient are Spring built-in APIs so are auto-configurable with Spring Boot. Latest versions of RestAssured (4.0.0 onwards) can    have problems with spring    boot(<a href="https://stackoverflow.com/questions/44993615">java.lang.NoClassDefFoundError: io/restassured/mapper/factory/GsonObjectMapperFactory</a>)    and require explicit dependencies addition.</p></li>
  <li><p>WebTestClient (a Fluent API) seems to have nice and easy to use syntax as compared to TestRestTemplate but is very new and there are    not enough examples showing its usage for non-reactive Rest APIs and    availability of extensive assertion API</p></li>
  <li><p>RestTemplate (API on which TestRestTemplate is based) will be deprecated in future Spring Boot version.</p></li>
  </ul>
  
  <p>Feedbacks from experienced developers will be a great help.</p>