What Makes a Good Test?
A project developed with TDD will have a lot of tests. But don’t assume that more or longer tests are always better. You need to have good tests. But what makes a good test?
We’re not going to be writing more code in this chapter. This chapter is more of a look back at some of the situations we’ve already encountered as well as referring to some tests in upcoming chapters. This is a chance to reflect on what you’ve learned so far and to look forward to upcoming topics.
A good test should incorporate the following elements:
- Be easy to understand – a good understanding will lead to better ideas for more tests and make tests easier to maintain.
- Be focused on a specific scenario – don’t try to test everything in one giant test. Doing too much in a test will break the first guidance of understandability.
- Be repeatable – tests that use random behavior to sometimes catch problems can miss...