I want to know if anyone of you guys use TDD in your c++ projects and how it performs compared to managed languages like C# and Java. And what frameworks you guys are using to automate tests on c++ projects?
-
1UnitTest++ is what I've used for a majority of my projects. – Jonathan Sternberg Jul 21 '10 at 13:50
-
Check out this series of videos on C++ and TDD: http://www.vimeo.com/album/254486/video/13240481 – Jon Reid Jul 23 '10 at 18:24
3 Answers
Two useful C++ test frameworks that don't seem to have been mentioned yet are Boost test
and Google Test
.

- 476,176
- 80
- 629
- 1,111
Test Driven Development is possible in any language. You need the right testing tools and methodologies for the language, and may possibly need a custom testing infrastructure for your project.
I have found CppUnit (at least 1.x) to be a very poor framework -- it seems to use Java/C# idioms in a C++ language and does not have support for STL constructs.
If you want a good example of Test Driven Development (in C), look at the Wine project -- http://test.winehq.org/data/ shows their test results across the different versions of Windows, Wine and the different commits into the Wine repository. They have their own custom test infrastructure.

- 7,945
- 1
- 26
- 28
-
Note that while people continue to use CppUnit, the original author (Michael Feathers) did a complete rewrite, briefly explained in _Working Effectively with Legacy Code._ His revised approach makes clever use of macros, which you can see in CppUTest, UnitTest++, and googletest. – Jon Reid Jul 23 '10 at 18:22
I recently moved from a C# project that was developed using TDD to a project that is using C++. I was dreading it quite a bit, but I find that doing C++ with TDD is a lot more enjoyable and the code is more robust than I remember from past (non-TDD) experiences with C++.
We are using Google Test. It is not as easy to use as NUnit/MbUnit, but it seems to work pretty well. There is also a Google mocking framework http://code.google.com/p/googlemock , but I have not been using that yet.

- 333
- 1
- 8