O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

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

Dependency Removal

Dependencies are the single most challenging issue in legacy testing. Perhaps the greatest virtue of well-done TDD code is that the tests force individual pieces of the code to be maximally independent of each other.

Without tests, legacy code tends to be highly interdependent. This makes adding tests difficult in several ways: multiple objects might need to be created to test a single method, or it might be hard to limit a test to a true functional unit if that unit is hard to reach or encased in some massive 300-line method. There are ways to have the code we need to test be separate enough to enable the tests we must write.

Keep Things Separate

Perhaps the easiest way to keep our new code from being dependent on legacy code ...

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