Blog 4

| No Comments | No TrackBacks

Unit testing has made my infinitely easier and it can make yours easier too. For the first couple years of my Computer Science education I did no unit testing whatsoever. My method for building a program was to write everything, and then start debugging. This is a terrible idea. If you've ever done this, you know that it just doesn't work well. Just a few small errors at the low level can make your higher level code unusable. These small errors mate with each other, creating weird problems at the high level. The program behaves in very odd unexplainable ways. At this point, it takes a long time to trace the error back to its source because you start at the high level problem, then have to check through a series of problems until you come to the original one. Wouldn't it just have been easier to write a test for your low level code in the first place? I have changed my poor coding practice ways. Now I write tests for each small component of my programs before using them at a high level. This way I know that my program has a solid foundation to stand on. You can implement this design process with a bunch of printf statements but there is a much easier way to do this. CxxTest is not difficult to use and all it requires is a C++ compiler. It is about as simple as #include'ing the test suite in your code and writing a bunch of assert statements where you want your tests to be. After doing this you can run your tests every time you make a minor change, and verify that the overall structure of your program has not changed. This way you can find a problem before it spirals out of control and creates some painful to fix problems.

No TrackBacks

TrackBack URL: http://blog.lib.umn.edu/cgi-bin/mt-tb.cgi/167848

Leave a comment

About this Entry

This page contains a single entry by marqu245 published on November 17, 2011 1:51 PM.

Blog 3 was the previous entry in this blog.

Find recent content on the main index or look in the archives to find all content.