5

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?

Diego Correa
  • 767
  • 2
  • 9
  • 22

3 Answers3

2

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

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
1

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
  • 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
1

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
  • 333
  • 1
  • 8