BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News InfoQ Article: Using Logging Seams for Legacy Code Unit Testing

InfoQ Article: Using Logging Seams for Legacy Code Unit Testing

In his book "Working Effectively with Legacy Code," Michael Feathers talks about finding seams in legacy code to facilitate testing. The definition he provides for a seam is "a place where you can alter behavior in your program without editing in that place." Types of seams vary among languages, and for Java he defines two categories that are relevant, "link seams" - whereby ordering the class path differently, different classes can be substituted for testing; and "object seams" - where calls to constructors or methods are made using a sub-class or mock implementation, rather than the originally expected class.

Ian Roughley, who is also a committer on the WebWork project, found that the logging seam can be quite useful; using this seam you can easily create unobtrusive unit tests around classes, without needing to edit class logic as well as avoiding behavior changes. Read more on InfoQ's latest article, Utilizing Logging Seams to Confidently Create Unit Tests around Legacy Code.

Rate this Article

Adoption
Style

BT