How do I get started doing unit testing in C++ ?
I have used Junit when coding in Java and found it very useful. Is there something similar in C++ ? What do you recommend ?
How do I get started doing unit testing in C++ ?
I have used Junit when coding in Java and found it very useful. Is there something similar in C++ ? What do you recommend ?
Here are similar questions that you may want to look at:
I recommend you check out Google's unit testing framework in addition to CppUnit.
I recently wrote a 5-part series of blog posts covering unit testing in C++ with boost. It gives step by step instructions for how to do this in Visual Studio.
Part 1: how to start making unit tests in C++ with Boost.Test.
Part 2: the assertion framework provided by Boost.Test in the context of a simple programming exercise that demonstrates test-driven development.
Part 3: continuing with test-driven development to complete the functionality of the PrimeFactors::Generate method.
Part 4: test-driven UI development.
Part 5: the facilities in Boost.Test for sharing common setup and teardown actions between tests and organizing tests into suites.
UnitTest++, legend has it that UnitTest++ was written by the author of this comparison of unit testing frameworks.
Good round up here.
We use Boost.Test, and we are able to do good cross platform continuous integration.
Take a look at this page: http://gamesfromwithin.com/?p=29
It is the best comparison of the C++ frameworks. I personally prefer Boost.Test.
I haven't been happy with any C++ unit testing framework. Since C++ doesn't have reflection, it's hard to write convenient unit testing tools. CxxTest is about as good as I've found. I've used it on some projects, but usually I just write my own tests either without a framework or using a crude framework I wrote myself.
I just started using googletest (https://github.com/google/googletest/). Its simple to integrate and I haven't had any problems with it.
My personal favorite is TUT. The two main reasons are that 1) it doesn't force Java-isms on you but takes advantage of what C++ is, and 2) you have control over it, writing the executable (I have a template I used), the reporting etc (provides a stream based version by default).
To me it very much follows the philosophy of KISS, 2 headers, no macros, no parsers, just plain old C++ code with a tiny bit of skeleton code.
I've just pushed my own framework, CATCH, out there. It's still under development but I believe it already surpasses most other frameworks. Different people have different criteria but I've tried to cover most ground without too many trade-offs. Take a look at my linked blog entry for a taster. My top five features are:
It also has Objective-C bindings.
Without knowing which platform/compiler you are targetting, I can only make a general recommendation. I've used this (CppTest) one quite successfully in the past. There's a simple framework called UnitTest++ that looks interesting.
Aeryn is another C++ Testing Framework worth looking at
© 2022 - 2024 — McMap. All rights reserved.