Chapter 9Coverage
In Chapter 7, Strategy, we generated an initial list of test cases based on a test strategy by analyzing the user-facing features of the Cards project. The tests in the ch7 directory of the book’s source code[31] are an implementation of those test cases, which test Cards through the API. But how do we know if these tests are thoroughly testing our code? That’s where code coverage comes in.
Tools that measure code coverage watch your code while a test suite is being run and keep track of which lines are hit and which are not. That measurement—called line coverage—is calculated by dividing the total number of lines run divided by the total lines of code. Code coverage tools can also tell you if all paths are taken in control ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access