In this chapter, you’ll learn to implement tests for your Spring apps. A test is a small piece of logic whose purpose is to validate that a specific capability your app implements works as expected. We’ll classify the tests into two categories:
- Unit tests—Focus only on an isolated piece of logic
- Integration tests—Focus on validating that multiple components correctly interact with each other
Tests are essential for any application. They ensure that the changes we make during the app’s development process don’t break existing capabilities (or at least they make errors less likely) and also serve as documentation. Many developers (unfortunately) disregard tests because they are not directly part of the app’s business logic, and, of course, it takes some time to write them. Because of this, tests seem to not have a significant impact. Indeed, their impact is not usually visible in the short term, but trust me, tests are invaluable in the long term. I can’t stress enough how important it is to make sure you properly test your app’s logic.