Unit Testing - The Advantages
Written by Andrew Johnson   
Saturday, 10 November 2012

Unit testing is almost a religion but what are the facts? This infographic puts the case for unit testing as simply as possible.

You need to keep in mind that this infographic was prepared by Typemock and hence it isn't exactly unbiased - consider it the case for unit testing prepared by a believer. Even if it only puts the positive side of the argument, you have to admit that there are a lot of positives.

 

Click for full sized version

bugsinfographic

 

Unit testing goes hand in hand with agile programming of all flavors because it builds in tests that allow you to make changes more easily. In other words, unit tests facilitate safe refactoring. The idea is simple: write some extra lines of code that perform tests that verify that a particular block of code - nearly always a function or a method - is behaving properly. You then work on the block until it passes all of the tests. If later on you decide that the block needs to be changed in some way, i.e. refactored, then the tests will indicate at once if you get it wrong. Refactoring without tests is dangerous because you aren't writing "green field" code but changing part of an interacting and working system, and this is much more difficult to get right. It is also claimed that unit tests form a sort of live documentation on what the blocks of code are supposed to do. While this is true, it is a poor level of documentation and not a reason for not write the good stuff.

The big problem with unit testing is that it is more code. And I guess you have to ask the question, who or what tests the unit tests? This isn't a silly question and yet it is one that currently isn't asked much or answered at all. We tend to ignore the simple fact that refactoring often not only disrupts the structure of the program but the structure of the tests as well. In short, unit tests are better than nothing but adding code to test code is not a good way to do it. Most of the criticisms can be fixed but so far the tools that we use are primitive.

 

bugsonaplan

 

More Information

Typemock.com

Related Articles

Essential Skills for the Agile Developer (book review)

VS Express 2012 WILL support Desktop Apps

 

blog comments powered by Disqus

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin,  or sign up for our weekly newsletter.

 

Banner


EF7 Drops XML Modeling Favors Code First
27/10/2014

Microsoft is dropping some ways of modeling data in the next version of Entity Framework (EF) to make the database tool more lightweight.



Learning To Be A Computer
29/10/2014

We have recently seen how much neural networks can learn, but the latest example is very strange. Google has succeeded in teaching a neural network to be a computer simply by showing it programs and w [ ... ]


More News

Last Updated ( Saturday, 10 November 2012 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.