Chapter 5FIRST Properties of Good Tests

Unit tests provide many significant benefits when crafted with care. But your tests also represent code you must write and maintain. You and your team can lose lots of time and sleep due to the following problems with your tests:

  • Tests that make little sense to someone following them

  • Tests that fail sporadically

  • “Tests” that don’t prove anything worthwhile

  • Tests that require a long time to execute

  • Tests that don’t sufficiently cover the code

  • Tests that couple too tightly to implementation, meaning that small changes break lots of tests all at once

  • Convoluted tests that jump through numerous setup hoops

In this chapter you’ll learn some key concepts and a few simple tactics that can help make your tests ...

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.