In this article, we will walk through Spring Boot Junit 5 example application to understand how to do Spring Boot 2 integration test with JUnit 5. Also test a simple GET rest api call using RestTemplate and also test a simple MessageService Spring component.

  1. Junit 5

JUnit is one of the most popular unit-testing frameworks to test the Java applications. The JUnit 5 version offers, with the goal to support new features in Java 8 and above, as well as enabling many other testing features.

2. Spring boot Junit 5 example application

2.1. Technologies used :

  1. Junit 5.5.2
  2. Spring Boot 2.2.2.RELEASE
  3. Spring 5.2.2.RELEASE
  4. Maven 3
  5. Java 8
  6. Spring Tool Suite 3.9.8

2.2. Spring Boot Junit 5 example project :

Spring boot junit 5 test application

3. Maven dependencies

Copy to Clipboard

4. Spring boot components

Following are the Spring components to test with Junit 5.


Copy to Clipboard


Copy to Clipboard

4. Junit 5 tests for Spring components

4.1. Junit 5 Test Case for

Copy to Clipboard

4.2. Junit 5 Test Case for

Following is the simple GET request API test with RestTemplate.

Copy to Clipboard