Thursday, May 1, 2014

A few words on unit testing

In short: I'm infected.

The more I use unit testing (mostly JUnit, but I'd like to get into it for C++ and Python), the more I like it.  It not only gives me a frame of reference for the correctness of code, but also helps me understand the purpose of sections of code more concisely.  I've even become a sort of automated testing evangelist, wanting to spread it's teachings to others (like at my job).  It appears that much of our woes in the software world come from a lack of acceptance testing; we think a piece of software is correct, though we've only used it a few times in ways we probably already know it works (these cases were tested throughly during development, most likely).  I'm starting to think more and more that automated acceptance/unit tests should be a requirement for every software project of significant size.  It's kind of a way to make an implementable version of the software specification and requirement documents.  Bugs are found faster.  Stress goes down because developers are less fearful to make changes or refactor, because they have a tool which can verify the correctness and functionality of the code base quickly.  I think my next step for my unit testing journey is to actually write some tests BEFORE I write the program that solves them.  It sounded crazy when I first heard of such a thing, but I think I'm ready :)

No comments:

Post a Comment