7. Legacy code is code without tests. Code without tests is bad code. -Michael C. Feathers Fraser Speirs http://www.flickr.com/photos/fraserspeirs/3395595360/
8. A characterization test is test that characterizes the actual behavior of a piece of code. It acts as a change detector, protecting legacy code form unintended changes
15. …A pinch point is a natural encapsulation boundary. When you find a pinch point, you’ve found a narrow funnel for all the effects of a large piece of code… -Michael C. Feathers Fraser Speirs http://www.flickr.com/photos/fraserspeirs/3395599536/
17. // This method is the "pinch point" we want to test... publicobjectCalculateSomething(objectsomeParameter) { // 1) Record input parameters... // 2) Do the work... // 3) Write parameters and return value to XML file. }
18. [TestMethod] publicvoidCalculateSomething_test1() { Run("Recordings/CalculateSomething1.xml"); } [TestMethod] publicvoidCalculateSomething_test2() { Run("Recordings/CalculateSomething2.xml"); } publicvoidRun(stringfilename) { // Load input parameters from XML file // Load return value from XML file // Call method under test // Use reflection to compare actual vs. recorded }