Does your code still work? Are you sure?

Posted on Tuesday 15 January 2008

I have been talking with quite a few people lately asking them what strategies they use for testing their applications. I was a bit surprised to find that most of them only do a little bit of functional testing by making sure that what they just wrote actually works. They don’t do testing to make sure that everything else still works.

When I was asking about testing, I was really asking about the unit testing that they do. Many knew what I was talking about, but some were less than familiar with this practice. For those of you that do not know what unit testing is, it is the practice of writing code that checks to make sure that small parts of your code work independent of other pieces of the system. In the short term it does not make a lot of sense, but when you have thousands of tests over an entire system you are much more likely to know when you break something….er….I mean introduce an undocumented feature.

Personally I go one step further and practice what is called test-driven development. Before I write any part of my system, I write a test first. At first this test will fail of course because the functionality isn’t there. Once I have my test written I write the small piece of the application. I know when I am done writing code when the tests finally pass. Then I am on to writing the next few tests. At first this is a bit different and takes getting used to, but once you feel comfortable with it you will wonder how you ever wrote strong stable software before.

A good tutorial for using JUnit (a popular open source testing framework) is available here http://junit.sourceforge.net/doc/testinfected/testing.htm

Share and Enjoy:
  • Digg
  • del.icio.us
  • Slashdot
  • Technorati
  • description

No comments have been added to this post yet.

Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.


RSS feed for comments on this post | TrackBack URI