blog_4

| 6 Comments

It is undeniable that testing is one of the most important parts of constructing a program, and unit testing is quite important among all kinds of testing. In my opinion, unit testing is the most fundamental test after writing the code, it guarantees that you do not do anything waste of time. Only if each part of the program works well, it is possible they function well after merging them together. It can be a disaster to suddenly realize that basic functions do not give correct outputs and it may be impossible to fix them when all things come together. And I think it is worth putting many efforts into unit testing. It seems to be a waste of time, it actually saves lots of time.
CxxTest is a good tool to finish the task. It provides a platform to do unit testing and make sure everything gets proper outputs before the programmer goes to the next step. When I first come across CxxTest, I got really confused how to use it. After reading some instructions and the examples, I found it quite easy to use. The most important thing during testing is thinking about the test cases. They should cover all the possible cases and some of them should fail, because there are no perfect codes. If every test case successes, it makes no sense because it doesn't help the programmer at all to fix the bugs. I believe that if this is done before really stating writing codes, it helps the programmer to build their program.
For our project, because the output of each file can be very long, it is hard to examine whether it is correct or not. And the unit test gives me a way to know whether I have done everything right, especially when I add something new into the existing code. This is the time that has the highest possibility to introduce some new bugs into the program. So after I add something new into the code, I do the unit test again to make sure no new bugs are imported. This is quite useful.
To sum up, I believe that testing, not only unit testing is essential when building a program and it is worth putting some time and efforts on it.

6 Comments

I also think testing is one of the most important parts of constructing a program. It makes sure that our program is doing exactly what its supposed to be doing. That is if you spend a lot of time writing very precise test cases. If your program has no test cases it may be missing small little crucial things that can become very troublesome. A program is not very useful if it is not doing what its supposed to be doing.

Xa Vang

CxxTest is a bit confusing in the beginning, but it turns out to be easy when you get to know it. The hard part about it would be making test cases. Good test cases should reflect on how the program should work. Knowing how your program works in all cases is a pain, but that is part of understanding your code.

Separating your writing into paragraphs makes it easier to read than when it is one huge paragraph.

Adel Aldawood

I totally agree with you that testing is one of the most important parts of programming. Although it might take a lot of time, I think it is worth it. Because if you are working on a big project and you don't do a unit test very often, when you combine all of the units together, it is almost impossible to fix all bugs.

Wenliang Tong

While I agree with you that unit tests are beneficial after newer functionality is added, I am not of the opinion that you should use them to test initial functionality of new features. I would favor a non test driven development model in which unit tests mainly verify that code that was once working still is.

Nate Martin

I hear a lot of people saying that they approve of unit testing. I do too, in theory. I am glad to have been introduced to it, but, in actuality, I'm not sold on the time investment vs. security gain. When you do a major overhaul on your code-base, how many of the tests will still refer to valid objects? How much work is refactoring the unit tests a ton of object interfaces have changed in the last overhaul? How often do you have to overhaul? Just throwing it out there as a devil's advocate.
Automated test suites that could identify a common data structure (array;linked list) and run a corresponding battery of standard tests on them would be super cool.

Gregory Setterholm

correction:
*How much work is refactoring the unit tests IF a ton of...

Leave a comment

About this Entry

This page contains a single entry by zhan1378 published on November 2, 2011 12:28 PM.

blog 3 subversion was the previous entry in this blog.

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