JUnit tests for the Spring Boot application

Spring Boot provides two modules for test support—sprint-boot-test and spring-boot-test-autoconfigure. spring-boot-test contains core items, and spring-boot-test-autoconfigure supports auto-configuration for tests. These modules have a number of utilities and annotations to help when testing your application. It is very simple to add these modules in the Spring Boot application by adding the spring-boot-starter-test starter dependency in your Maven file. This starter imports both Spring Boot test modules as well as JUnit, AssertJ, Hamcrest, and a number of other useful libraries. Let's see the following Maven dependency to include test support in the Spring Boot application:

<dependency> <groupId>org.springframework.boot</groupId> ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.