O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use Unique Values

The readability and usefulness of tests are enhanced when the values used to construct fixtures are mutually distinct. Within a test, unique values reinforce the differences between various assertions and help highlight when the implementation has miswired parameters or properties. Between iterations of a data-driven test, distinct values help to highlight the failing test case more clearly. The same effect applies between tests, in which case unique values also help to identify the effects of shared state.

Assertion failures generally provide good feedback on the values involved and the location in the code. However, some assertions, like assertTrue, do not display their contributing expression values. Assertions in loops ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required