J and I and Me
2012-04-01
  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.

  13:04
Bookmark and Share
Comments:
I'm not going to argue the main point of the article. At least not directly.

But I noticed that there are two wrong statements and one true that doesn't get elaborated enough.

1. Unit testing didn't start with JUnit. AFAIK JUnit was basically a migration of a Smalltalk tool.

2. By far not all programmers do write unit tests. If we are lucky maybe 50% write any relevant amount of unit tests. They just don't hang out on twitter and their blogs and brag about it.

3. Sure with bad brakes everybody would drive more carefully. But you can improve on that. Just make the ignition so bad that no car would start. Problem solved ... or maybe not.

Go figure
 
There are two very important cases for tests that even a correct code can not replace:

- Tests help refactoring when the requirements change .. and they will change

- Good tests show the requirements. In fact they are most times the only place where the requirements can be found
 
April Fools' Day?
 
April Fools' Day?
 
@Jens : In fact you are right, unit testing started in the Smalltalk community

@Sebastian: Absolutely correct!
 
Kommentar veröffentlichen

<< Home
J for Java | I for Internet, iMac, iPod and iPad | Me for me

ARCHIVES
Juni 2005 / Juli 2005 / August 2005 / September 2005 / Oktober 2005 / November 2005 / Dezember 2005 / Januar 2006 / Februar 2006 / März 2006 / April 2006 / Mai 2006 / Juni 2006 / Juli 2006 / August 2006 / September 2006 / Oktober 2006 / November 2006 / Dezember 2006 / Januar 2007 / Februar 2007 / März 2007 / April 2007 / Mai 2007 / Juni 2007 / Juli 2007 / August 2007 / September 2007 / Oktober 2007 / November 2007 / Dezember 2007 / Januar 2008 / April 2008 / Mai 2008 / Juni 2008 / August 2008 / September 2008 / November 2008 / Januar 2009 / Februar 2009 / März 2009 / April 2009 / Mai 2009 / Juni 2009 / Juli 2009 / August 2009 / September 2009 / Oktober 2009 / November 2009 / Dezember 2009 / Januar 2010 / Februar 2010 / März 2010 / April 2010 / Mai 2010 / Juli 2010 / August 2010 / Oktober 2010 / Januar 2011 / Februar 2011 / März 2011 / April 2011 / Mai 2011 / Juni 2011 / August 2011 / September 2011 / November 2011 / Februar 2012 / April 2012 / Mai 2012 / April 2013 / Mai 2013 / Juni 2013 / Januar 2015 / Juli 2015 / Februar 2016 /

Links

Twitter
Google +
Slideshare
Prezi
XING
LinkedIn
Das Spring Buch


Feeds

Feedburner


Impressum
Betreiber und Kontakt:
Eberhard Wolff
Leobschützer Strasse 22
13125 Berlin
E-Mail-Adresse: eberhard.wolff@gmail.com

Verantwortlich für journalistisch-redaktionelle Inhalte:
Eberhard Wolff