views:

120

answers:

4

Hello guys, 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?

+1  A: 

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.

reece
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
A: 

Check this for the benefits and vulnerabilities http://en.wikipedia.org/wiki/Test-driven_development

Your own requirements and how you would proceed further is more important than picking up the fad methodology.

If you use Eclipse for C++ development, you can use the TDD available with Eclipse.

DumbCoder
+2  A: 

Two useful C++ test frameworks that don't seem to have been mentioned yet are Boost test and Google Test.

Jerry Coffin
+1 for Google Test
TheJuice
A: 

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.

mdenomy