Testing Considered Harmful
Unit testing started with JUnit - and was infectious. As you can see in
JUnit Test Infected: Programmers Love Writing Tests that was the intention from the very beginning. And so the infection spread.
Nowadays almost all programmers do extensive Unit Tests. And therefore we see problems arising. Instead of thinking about a problem and building a reliable solution developers now just write a test and code away. At one point they get a green bar and consider the job done. But can you build proper software that way? Dijkstra stated in 1972: "If you want more effective programmers, you will discover that they should not waste their time debugging, they should not introduce the bugs to start with." - see
Wikiquote. I think the same holds true for testing. So instead of the ever famous code-test-refactor cycle we could use more of the
Feynman Way of Solving Problems. If you really think about the solution first you will find you won't need a test. Instead you will actually write correct code from the beginning. You won't need to rely on tests. They cannot show the absence of bugs anyway - as Dijkstra mentioned. In the end you will end up with cleaner code and less code - as there are no tests to be written.
This principle can be applied to other areas as well. I think one reason why there are so many car accidents are the very effective brakes cars have now. If we had less effective brakes people would think about possible problems beforehand, drive more carefully - and we would have less accidents.
J for Java |
I for Internet, iMac, iPod and iPad |
Me for me