6.1. Commented-out tests
I don’t know who originally came up with the idea that programmers should be able to sprinkle nonexecutable comments into their source code. (If you know, please tell.) I’m glad that we have that ability, as comments can be of great help in trying to understand code.
But often, comments backfire by confusing or even misleading us. Related to tests, a particularly interesting failure mode with comments is a test method that’s been commented-out, as it doesn’t communicate anything and just confuses people. When we do that, we’re not commenting anything—we’re using comments as a poor man’s version control.
Let’s take a look.
Not long ago I was digging out code I’d written for a project from half a decade ago. ...