8

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 ...

Get Test-Driven Development with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.