views:

1002

answers:

5

I've been reading a lot about Unit tests and Test Driven developemnt.

Recently, I also read java unit test code.

I however, prefer to develop in Qt. So I googled up "unit testing in c++" and found a host of information about various unit testing frameworks available for C++.

However, I could not find a reliable comparison of the the various frameworks.

So I look to the SO community to guide me through the selection of what may the "best" unit testing framework for c++.

Also, if anybody had specific comments regarding TDD in Qt (especially using Qt-Creator), then they are more than welcome.

jrh.

+1  A: 

Boost is usually a good choice, and it contains a testing framework, the Boost Test Library. I have used it for small test cases and it did what I expected, but I haven't used it extensively like in TTD.

sth
+3  A: 

This seems too be the same question as:

http://stackoverflow.com/questions/387272/unit-testing-in-c which is actually c++ despite the URL title.

From there, they link to two more SO questions which should help:

http://stackoverflow.com/questions/91384/unit-testing-for-c-code-tools-and-methodology http://stackoverflow.com/questions/87794/c-unit-testing-framework

NoahD
+2  A: 

The "xUnit" family of testing frameworks is usually pretty solid (jUnit, NUnit, etc.). I haven't used it myself, but there is a port of jUnit for C++:

http://sourceforge.net/projects/cppunit

Andy White
cppUnit is very easy to use and run - we use it in a commercial environment, testing over 50 separate Dlls, each with a few thousand test cases. It's proven to be very reliable and flexible.
Thomi
+10  A: 

Usually use Boost, but if you are using Qt, their QTestLib might be the better choice.

stephan
just what I was looking for :)
Here Be Wolves
I dont know about Boost so much but the biggest downside of QTestLib is that it isnt reliable with crashes - eg if your unit crashes, your whole suite crashes and then the report will be hard to parse (if you rely on that feature, for example in automatic test reporting).
rasjani
+2  A: 

There is a table comparing all (?) the C++ unit test frameworks available from wikipedia.

There also is an old comparison of C++ unit test frameworks available. I do not think it has not been updated so I mention it as a complement as it's more argumented than the table. It covers, CppUnit, CppUnitLite, Boost.Test, NanoCppUnit, Unit++, CxxTest, especially it does not cover Google C++ framework.

philippe
Boost.Test at least has been heavily extended and improved since the gamesfromwithin article was written. The same is probably true for the other frameworks as well, but I don't use those, so can't say for sure.
jalf