
- Image by ecstaticist via Flickr
Some of you may remember my writing about how unit testing is anti-productive and those of you I have to disapoint, I still dont’ think it’s the best productivity tool out there.
BUT!
The past few days I had another go at unit testing while developing a “server” for gathering statistics on how people use Twitulater. This was mostly in preparation for making a “server” for syncing Twitulater users, more on that some other day, it was mostly a learning exercise.
What I learned was that:
- Unit testing is no guarantee for quality (con)
- Unit testing can be really cumbersome to use and more time can be spent finding a test than solving the problem. Like for example: How do you test an app that reads from sys.stdin? (con)
- Unit testing only helps with bugs you’ve anticipated or found (con)
- Unit testing can quickly lull you into a false sense of perfection (con)
- Unit testing is a life-saver when you’re refactoring (pro)
- Unit testing is extremely gratifying – nothing better than finally seeing all those tests pass after a long night for a sense of achievemt (pro)
- Unit testing feels easy to use after the tests are written (pro)
- Unit testing provides repetitive and verifiable measurments – the scientific method! (pro)
- Unit testing is great for verifying behaviour under strange conditions – very easy to test for sturdines against idiocy - (pro)
- You quickly learn to love it (pro)
So there you have it, four cons versus five pros. I guess unit testing actually is good and I am forced to somewhat eat my words … but I still think it should be easier to do integration testing. Sure, very easy to mimick an input straight to an object. But how on earth can you test an application actually reads input as expected?
Or, how exactly do you test the output of something? Just because all the return values are correct, doesn’t mean the actual output is as well. And what about GUI’s? I would love to have a way of testing my GUI looks like I expect it to without having to keep reruning the application … ideally, unit testing would be so good that after the tests pass I can be certain everything works and ship it without ever having run what I’m working on. But I don’t think we’re getting that any time soon.
Related articles by Zemanta
- The 7 Phases of Unit Testing (codebetter.com)
- Refactoring: Improving the Design of Existing Code (dobrzanski.net)
Tags: Programming, Software testing, Twitulater, unit test
or see the music I like on last.fm,
or perhaps leave a comment, I like comments,
or go do your job because I know you're slacking,
or go write a blog of your own,
or tweet about something interesting,
or go out and have some fresh air,
or find a girlfriend,
or a boyfriend,
or a manbearpig,
or for fuck's sake stop reading this already,
no?
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=715fbfbd-35c8-4c51-a8df-ac6e876e19c5)
4 comments so far
Leave a reply