In the previous chapters, we introduced testing software, began to explore testing with JUnit, and presented different test methodologies. Now that you are writing test cases, it is time to measure how good these tests are by using a test-coverage tool to report what code is executed by the tests and what code is not. This chapter will also discuss how to write code that is easy to test and finish by taking a first look at test-driven development (TDD).
Writing unit tests gives you the confidence to change and refactor an application. As you make changes, you run tests, which give you immediate feedback about new features under test and whether changes break the existing tests. The issue is that these changes may still break untested functionality.