Diego Correa
Diego Correa

Reputation: 777

It is possible/productive enough to TDD in C++ projects?

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?

Upvotes: 5

Views: 937

Answers (3)

mdenomy
mdenomy

Reputation: 333

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.

Upvotes: 1

Jerry Coffin
Jerry Coffin

Reputation: 490218

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

Upvotes: 2

reece
reece

Reputation: 8155

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.

Upvotes: 1

Related Questions