10 Unit testing principles
This chapter covers
- The basics of unit testing
- What makes a good unit test
- Test doubles, including when and how to use them
- Testing philosophies
Every time an engineer modifies a line of code there is a risk that they might inadvertently break something or make a mistake. Even extremely small, innocent-looking changes can have bad consequences: “It’s just a one line change” are famous last words before a system crash. Because every change is risky, we need a way to reassure ourselves that the code is working, both initially and whenever it’s modified. Tests are often the main thing that give us this reassurance.
As engineers, we usually concentrate on writing automated tests. This means we write test code that exercises ...
Get Good Code, Bad Code 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.