The TDD Test
Eljay-Adobe
Posted on October 4, 2018
The TDD Test
I have had some experience with co-workers who were doing TDD incorrectly.
The benefits of TDD is that it puts pressure on the developer to use employ several of the SOLID principles, to design for testability, high cohesion, low coupling, and the immediate elimination of technical debt by refactoring before checking in.
In order to underscore the TDD value proposition, I have found that adding one simple little step to the TDD process helps educate developers on how to do TDD correctly.
If the developer is doing TDD correctly, then the additional step won't devalue the process.
I call this The TDD Test. It tests the TDD process.
- add a test
- run the test - it should fail
- write the code
- run the test - it should pass
- refactor the code - eliminate newly incurred technical debt
- run the test - it should pass
- check-in
- delete the test
- check-in
Sure, this loses the residual value of the test. But keep in mind that 99% of the value proposition of TDD is how it guides design-in-the-small.
(The residual value of the test can be recovered from source control. Which is why step 7 is before step 8.)
The TDD Test does not have to done in perpetuity. Just until everyone understands how TDD works.
James Coplien
At the extreme end of the unit testing spectrum is James Coplien. In his “Why Most Unit Testing is Waste” essay, he advocates keeping tests for up to a year, and then getting rid of them.
I do not share Coplien’s opinion, however he makes an interesting case. Depending on your software, what he advocates may be applicable to your situation. I do not believe his advice is applicable in the kinds of software I create.
Coplien is using waste in the sense of Lean’s Muda. He is not using it in the sense of “testing is a waste of time”.
I mention Coplien’s article because The TDD Test was inspired by his paper. The TDD Test just changes his “...up to a year...” part into “...up to a minute...”.
Posted on October 4, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 26, 2024
November 21, 2024