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.
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.1. Technologies used :
- Junit 5.5.2
- Spring Boot 2.2.2.RELEASE
- Spring 5.2.2.RELEASE
- Maven 3
- Java 8
- Spring Tool Suite 3.9.8
2.2. Spring Boot Junit 5 example project :
Following are the Spring components to test with Junit 5.
4.1. Junit 5 Test Case for MessegeService.java
4.2. Junit 5 Test Case for HelloController.java
Following is the simple GET request API test with RestTemplate.