jrharshath
jrharshath

Reputation: 26583

Unit testing in C++

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.

Upvotes: 11

Views: 8109

Answers (7)

user2827968
user2827968

Reputation:

If you want to get off the ground quickly without figuring out how to build a library, there is a single header file include solution, which supports fixtures (setup and teardown), the usual TEST() {} with CHECK_TRUE, etc. It also has memory leak detection and performance testing capabilities.

https://gitlab.com/cppocl/unit_test_framework

Upvotes: 0

onqtam
onqtam

Reputation: 4548

I would recommend doctest (created by me) - it's the lightest on compile times from all the popular testing frameworks. It is also a direct competitor to Catch which is currently the most used framework - checkout the differences in the FAQ

Upvotes: 5

stephan
stephan

Reputation: 10275

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

Upvotes: 18

philant
philant

Reputation: 35856

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.

Upvotes: 3

Andy White
Andy White

Reputation: 88475

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

Upvotes: 2

NoahD
NoahD

Reputation: 8302

This seems too be the same question as:

Unit testing in C++ which is actually c++ despite the URL title.

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

Unit testing for C++ code - Tools and methodology C++ unit testing framework

Upvotes: 3

sth
sth

Reputation: 229864

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.

Upvotes: 1

Related Questions