This chapter covers
- Why we test
- How we test
- Test-driven development
- Test doubles
- From JUnit 4 to 5
Recent years in programming have seen a growing acceptance of automated testing as an expected part of the development process. Tests are run both locally by developers and in build and continuous integration environments to ensure our systems are behaving. Along with that has come an explosion of different tools, approaches, and philosophies.
As with any technology, there are no silver bullets - no approach to testing will cover every possible situation. Given this, it’s important to understand why you are testing so that you can determine best how to test.
In fact, that word "test" hides a multitude of possible reasons we’re examining our code’s behavior. A non-exhaustive (and occasionally overlapping) list to consider: