Testing Spring Boot applications
As you might have read in the previous section, there are some different strategies and approaches to the tests in your application. I have briefly mentioned all of them, so now we may proceed to the practical aspects. Spring Boot provides a set of utilities that help in the implementation ofautomated tests. In order to enable these features in the project, you have to include thespring-boot-starter-test
starterto the dependencies. It imports not only thespring-test
andspring-boot-test
artifacts, but also some other useful test libraries, such as JUnit, Mockito, and AssertJ:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
Building the sample application
Before we start to work on automated tests, we need to prepare a sample business logic for testing purposes. We may use the same example system from the previous...