Spring application testing
Earlier on in this book, we discussed application testing and why it is necessary in creating reliable software. We must now explore the process of testing Spring applications. A Spring application can be tested in four easy steps:
- Add necessary testing dependencies to the project
- Create a configuration class
- Configure test class to use custom configuration
- Write required tests
We shall look at each of these steps one by one.
Adding necessary testing dependencies to the project
This involves the inclusion of suitable testing dependencies in your project. Open the Place Reviewer
project's pom.xml
file and add the following dependencies:
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> <exclusions> <exclusion> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> </exclusion...