Adding JUnit 5 to the application
The first step in writing test cases is adding the necessary test components. The most widely accepted test tool is JUnit. JUnit 5 is the latest version with deep integrations with Spring Framework and Spring Boot. (See https://springbootlearning.com/junit-history for more history of the origins of JUnit.)
What does it take to add JUnit to our application?
Nothing at all.
That’s right. Remember how we used Spring Initialzr (start.spring.io) in previous chapters to roll out our new project (or augment an existing one)? One of the dependencies that was automatically added at the bottom is this:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
This test...