Jump to content

  • Log In with Google      Sign In   
  • Create Account


Messy unit tests, rewrite or keep them and add substitutes?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 wqking   Members   -  Reputation: 756

Like
0Likes
Like

Posted 23 September 2012 - 12:56 AM

I have a C++ library, and I will develop and maintain it for quite long time (at least several years).
So robust unit tests are very important to back up the library quality.

Now there are more than 600 unit test cases, 21000 LOC. Note some test cases are really large, not small cases.
Currently the unit tests are a little messy, because I wrote most them when I didn't have much experience on unit testing (still not for now :( ).

Two biggest problems are,
1, The unit tests don't cover all or most code. That's not because of there are not enough unit test, but the unit test structure is a little wrong.
2, I'm a lazy developer and always want to find easy way to do my work. So a lot of unit tests are coupled together via common code, which is not fine for unit test, IMHO.

My question is, should I rewrite the whole unit tests, or keep current unit tests there and add a complete new unit test system?
I don't think current unit test code base can be reused in new unit tests because the current unit test structure/organization is not very good. I need to restructure them.

http://www.cpgf.org/
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.5 was released. Now supports tween and timeline for ease animation.


Sponsor:

#2 RobTheBloke   Crossbones+   -  Reputation: 2225

Like
1Likes
Like

Posted 23 September 2012 - 07:29 AM

My question is, should I rewrite the whole unit tests, or keep current unit tests there and add a complete new unit test system?

Life is too short to spend time rewriting unit tests. Enjoy time writing new fun exciting bits of code instead.

I don't think current unit test code base can be reused in new unit tests because the current unit test structure/organization is not very good. I need to restructure them.

Then keep the tests you have, and enhance them with new tests for the new aspects of the code you write. Unit tests can exist in more than one executable. The only real time it's worth doing any serious refactoring work on tests, is if you need to change the framework for better test reporting. So if you are convinced that rewriting your unit tests is a good idea, I'd recommend that you first set up a CI/build server (somethink like jenkins for example). AT least you'd know then, that the refactoring work you do, will probably be the last time you ever need to do that (well, probably not the last, but should be good for 5 years or more).

So a lot of unit tests are coupled together via common code, which is not fine for unit test, IMHO.

If the common code is reliable (i.e. tests exist for it), then there is nothing wrong with that approach.

The unit tests don't cover all or most code. That's not because of there are not enough unit test, but the unit test structure is a little wrong.

Code coverage tools will help you identify any untested code paths, although generally, the law of diminishing returns applies once you get past 80% coverage or so.

Edited by RobTheBloke, 23 September 2012 - 07:32 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS