20 Testing Java Persistence applications
This chapter covers
- Introducing the testing pyramid and examining persistence testing in its context
- Creating the persistence application to test using Spring Boot
- Using the Spring TestContext Framework
- Working with Spring profiles to test Java persistence applications
- Demonstrating execution listeners to test Java persistence applications
All code needs to be tested. During development, we code, compile and run. When we run, we may sometimes test how our code works. Persistence applications mean more than this. They have the particularity that our code interacts with the external database and how our program works may be dependent on it.
20.1 Introducing the test pyramid
In previous chapters, we focused on developing the code to interact with the database. We examined different alternatives to do this, and different frameworks and we interacted with various databases. We need to make sure that our programs are safe and bug-free. We need to be able to introduce changes without creating bugs, add new features without impacting the old features, and refactor code without breaking existing functionality. This is the purpose of this last chapter.