O'Reilly logo

Beyond Legacy Code by David Scott Bernstein

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

Let’s Get Practical

Here are some ways to put these ideas into practice.

Seven Strategies for Using Tests as Specifications

Writing unit tests to specify behaviors keeps development focused on building only what’s needed. It also helps you limit the tests you write to only those that specify the behavior you’re creating. Not only do these tests document how to use the behaviors you create, they also show the sequence in which you built a feature, which gives insight as to how the software was designed. Here are seven strategies for using tests as specifications.

Instrument your tests

Instead of using hardcoded values as parameters, assign those values to variables that are named for what they represent (for example, maxUsers instead of 20). This ...

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