Test-Driven Exploration

Testing a legacy codebase starts in earnest when there is a change to make. Often the first order of business on a new project is to deal with a critical bug left by the previous team—something that must be accomplished while preserving existing behavior and that does not demand a dramatic refactoring of the application.

In this case, there are two goals to getting the code under test. You want to be able to tell when the bug has been fixed. This step involves a more or less standard TDD bug-fixing session with one or more failing tests isolating the bug. The tests should pass when the bug is fixed. Also, you must confirm that any existing correct behavior hasn’t been compromised. In a project that was TDD from the ...

Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.