Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ unit tests

Started by Thorris Dec 2, 2004 at 9:44 AM 5 replies 1.2k views
Original Post
Thorris
Thorris
Hello, does anyone know a good framework for unit tests in C++. I know NUnit, but I think it is only for managed languages in .NET. Ciao, Thorris.
Morbo
Morbo
Check out cppunit. I've used it for a few projects. It's a little primitive in some regards (eg. doesn't have the robust collection of libraries available that JUnit has), but it's effective and easy to use.
chollida1
chollida1
I'd second the use of CPPUNIT, we useit for automated builds as well as post compile chekcing on the dev systems.

We also use it ON OS X wihtout changing any source code.

Cheers
Chris
CheersChris
Anon Mike
Anon Mike
I've never understood why people seem to think they need some sort of framework to make unit tests. I find they just get in the way and make debugging failed tests harder.

For me an ideal unit test has these features:

Small - I can throw it on a floppy if I have to.
No installation - if I have to do anything other than xcopy something is wrong.
One file - Fewer files to keep track of is good.
Little overhead code - I don't want to have to step through 1000 lines of boilerplate/framework code to get at the problem.
No special environment - I don't want to have to remember to set environment variables, make sure some logging server is just so, etc.

etc. Basically what it comes down to is that the more effort it takes to run the test (and interpret the results) the less likely devs are going to actually run them.
-Mike
chollida1
chollida1
We've never had a problem with the framwork, its small, lightweight and it does all sorts of formatting, automatically exports the results to xml and outputs them in the debugger window. None of these come for free if you write your own.

But some people still have the not inveted here syndrome. If someone has a problem with CPPUNIT I'd love to hear it:)

CHeers
Chris
CheersChris
corliss
corliss
I found a framework called tut. It is based on templates so the compiler needs to have good support for them. I have used it at my job and it works fairly well. There is some code you have to provide to format the output, but nothing major. Just an alternative to cppunit. Not that it is bad nor is this one better. Just different approaches to the same problem.

http://tut-framework.sourceforge.net/

Chris
Thorris
Thorris
Hello,

I also found out about TUT. I will take a look at both.
Thanks.

Ciao, Thorris.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.