Jake Worth discusses how developing legacy code is inevitable. Every production application will, at some point, become a legacy application.
In order to properly work on legacy applications, tests are a prerequisite.
Unit tests get the closest to specifying application behavior, but can still fall short.
Genesis of idea: Working Effectively with Legacy Code book by Michael Feathers.
"In nearly every legacy system, what the system does is more important what it's supposed to do." - Feathers
A characterization test is a test that characterizes the actual behavior of the code.
Process:
This is backwards from normal TDD, but will allow you to build test coverage for a working application for the purposes of being able to refactor code.
After this process is completed, write additional tests on a case by case basis.
"A gold master test is a regression test for complex, untested systems that asserts a consistent macro level behavior."
The goal of this test is to ensure that the application continues to work, even when making future changes.
This can help give insight on the underlying behavior when adding new features in the future.
pg flags
for scrubbing)When the test fails:
The gold master test provides a high level test for an application's full functionality that includes testing against production data instead of test data, including HTML and actual database.