o-ni

o-ni

Monday, November 7, 2011

imagine you just finished writing 2000 lines of code. now to see if it works... nope, not working. now what? this kind of hopeless situation is exactly what unit testing and cxxtest are used to prevent!

unit testing is the practice of testing if each tiny component of the program works correctly as soon as it's built/linked together with other parts into a bigger unit. this is a practice recommended exponentially more with the size of the program. Why? Because YOU WILL NOT GET EVERYTHING RIGHT THE FIRST TIME AROUND! Then the butterfly effect multiplies it many times over depending how deep in your program it is. these tend to be horrible and hard to find errors that unit testing saves you from.

unit testing is very useful, but constantly testing every single piece of code is a pain. this is where cxxtest comes in. cxxtest is a tool that helps automate testing. this allows you to test more and easily, thereby making unit testing more doable.

in conclusion, unit testing is necessary and cxxtest makes it workable. this can save you a great deal of work, headache and time. i know it did me.

4 comments:

Unknown said...

It's interesting that you brought up the butterfly effect. One small change in the code can completely change the behavior of the program. Sometimes it can even break other components of your program. It has happened to me too many times. Life becomes a lot easier when you combine unit testing with regression testing.
— Dylan Bettermann

Christopher Jonathan said...

I like how you make the first statement about testing. I'm totally agree that testing should be done step by step instead do it at the last. I think you should mention that cxxtest can only be used by C/C++ programming language and what is the advantage of using cxxtest rather than other testing tool.

Christopher Jonathan

Unknown said...

The butterfly effect is a good analogy. No matter how minor the mistake, it definitely may still have a large effect. I've also discovered that problems like this are a real pain to detect. Likewise the wind generated by a butterfly would very likely be overlooked by a weather radar.
- Ian Ryan

Huy Tran said...

I like your entry. This is one of the entries that are short but successfully cover the important points.
Also, the point about butterfly effect that makes the problem exponentially bigger with the depth of the program is very nice.

This would have been perfect in my opinion if you had added in the point that testing does not make programs bug-free.

-Huy Tran