Fog Creek Software
Discussion Board




C++ Unit Test Packages

What unit test software do you use? For Java there's JUnit which seems to be the standard. On C++ I located these packages:

* CppUnit: best-known C++ unit test framework, derived from JUnit, abandondened by the original author because requests from the community were far too diverse, IMHO quite a beast to work with, GUI is quite simplistic (not much of a problem)

* QtUnit: based on CppUnit, but ported to use the Qt library, heavily refactored code, which looks much better, nice DLL/so support, nice GUI, lack of any documentation, no community to speak of, needs a license from Qt for Windows dev

* CppUnit Light: very basic and easy to use, looks good to me

* Unit++: seemed to be very basic and uncomfortable to use

* boost::test: no idea how good it is

Any experience, suggestions or rants?

Sebastian Wagner
Thursday, January 02, 2003

I typically use cout and diff.

Danil
Thursday, January 02, 2003

What do these have to do with unit testing?

Sebastian Wagner
Thursday, January 02, 2003

I think the point is that you can just start writing tests.  These "frameworks" are all very simple things that will emerge naturally, and customized to your needs, by simply writing tests and refactoring them.

Unless, maybe, you want a GUI.  But I have no idea why you'd want one.  Hitting an up arrow to re-run the tests is no harder than pressing a button.

Bob

Robert
Thursday, January 02, 2003

The great thing about using cout and diff is that unit tests are *fully automatable* which means you can just run them as part of your nightly builds. Don't know if the other frameworks mentioned can do this or not.

Don't let the framework be too complicated or it will be just another barrier to get people to write tests.

Jeff Kotula
Thursday, January 02, 2003

All of the XUnit frameworks can be automated also and added to your builds.

What they do is allow you to write complicated test without having to write your own framework. For instance, in one of my unit tests I have to base64 encode an item and save the output to a file. I then have to assert that the size is correct BUT using base64 will not always have the same output size (original size/3*4) due to padding at the end of file. Fortunately I know that the output will be within a certain delta and the XUnit framework has an AssertEquals(Float, Float, delta) method that accounts for deltas.

// example assertion:
AssertEquals(newSize , originalSize, delta);


If I had to write this AssertEquals method or others it would have been a waste of my time.

Ian Stallings
Thursday, January 02, 2003

this wiki page lists a few more:

http://c2.com/cgi/wiki?WhySoManyCplusplusTestFrameworks

I haven't had tried any of them myself, but look forward to hearing other people's opinions.

Keith Wright
Thursday, January 02, 2003

*  Recent Topics

*  Fog Creek Home