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:
- Ensures compatibility with Spring boot for incremental versions.
- Easy-to-use and extensive assertions for checking status codes, headers, both JSON/XML payload validation, response time, etc.
- Has the possibility to test spring container configuration.
- Features to reuse specific checks across all end points.
- Is the most stable and therefore an Industry common practice.
Few initial findings which sort of prevent one of them to be marked as clear winner are:
TestRestTemplate & 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(java.lang.NoClassDefFoundError: io/restassured/mapper/factory/GsonObjectMapperFactory) and require explicit dependencies addition.
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
RestTemplate (API on which TestRestTemplate is based) will be deprecated in future Spring Boot version.
Feedbacks from experienced developers will be a great help.