April 23, 2015
Why Most Unit Testing is Waste (An Exploration)
—A look at James O. Coplien's article on waste in unit testing.
A team member shared a copy of "Why Most Unit Testing is Waste"
by James O. Coplien. I was so impressed that I read it cover-to-cover. Coplien identifies unit test smells that indicate waste in unit testing. A follow-up article, “Seque
” provides more insight on these ideas.
Coplien isn’t against unit testing. He’s for the intelligent use of unit testing and sees more value in the creation of tests that focus on features. This shifts the focus of the unit under test from a method to a feature.
Focusing on features is necessary because it is the only system artifact capable of providing an explicit calling structure (or context) for the objects (and methods) it relies upon. An explicit calling structure is required to reason about the execution of a program.
Value is tied to Lean Manufacturing
and eliminating waste, including overburden and value in the form of what customers will pay for. To eliminate waste, evaluate your test mass using a criteria based upon business requirements. Focusing on Lean Manufacturing means that fewer unit tests are created and that test effort is directed at activities providing more value (feature testing).
Coplien provides an example of Lean development using a map. It’s informative that shows how generalization introduces waste. Unit testing over generalize the map to the point where they exceed the requirements of the application. That’s waste that would be avoided if feature testing were used.
In “Seque”, Coplien argues against automation in support of continuous improvement: automation provides a one-time benefit and that to enjoy continuous improvement people need to remain involved. Another argument is autonomation
and is directed at supporting the notion of testing as a heuristic activity and is part of the same argument against attempting to automate intellectual tasks.
For other views on Coplien’s articles review of Reddit
and Hacker News
. Many of the links provided in the Hacker News article are insightful and the commentary a little more reasoned over that of Reddit.
The main message I get from Coplien’s articles is that good tests are the result of a focused intellectual activity directed at reducing the risk of program failure and that this activity should focus features. Use autonomation, not automation, if you want to continuously improve quality.
2019-04-14: Replaced the link to autonomation as the original went dead.