Spring Boot - Testing JSON Serialization and Deserialization With @JsonTest - Example
In this section, we will learn how to test JSON Serialization and Deserialization With @JsonTest in Spring Boot application. 1. @JsonTest Instead of bootstrapping the entire application context for every test, @JsonTest initializes the Spring application context with only those beans needed to test JSON serialization and deserialization. @JsonTest annotation can be used to test slices of our application and the auto-configuration that it import by default are listed below: org.springframework.boot.autoconfigure.cache. CacheAutoConfiguration org.springframework.boot.autoconfigure.gson. GsonAutoConfiguration org.springframework.boot.autoconfigure.jackson. JacksonAutoConfiguration org.springframework.boot.autoconfigure.jsonb. JsonbAutoConfiguration org.springframework.boot.test.autoconfigure.json. JsonTestersAutoConfiguration Testing JSON Serialization and Deserialization Example 2. Creating a spring boot application First, open the Spring initializr https://start.s...