Unit Testing information
Brief outline of Test Driven Development -- for more detail, Kent Beck's book is good
Available packages include
- CppUnit -- LGPL
- CppUnitLite -- lightweight alternative to CppUnit designed to improve portability, understood to be freely redistributable.
- CppUnitLite (version by Keith Bauer) -- CppUnitLite edited to prevent all g++ warnings -- see license
- CxxTest -- requires perl/python, LGPL
- UnitTest++ -- developed from CppUnitLite to address its limitations (by the author of the Suite comparisons), has a more restrictive license
- Google C++ Testing Framework -- xUnit format, BSD license.
- Swig linkage to perl, python etc. means that numerous other frameworks could be used, but it seems as well to work in native C++.
Some suite comparisons are available.
In deciding which way to go, we need to think about Licensing. It would be good for the framework available from the repository, but most of these packages require the (free to modify) licenses to be redistributed with the source.
A pdf article is available outlining a process for instrumenting legacy code -- see Michael Feathers' book for further detail
Comment on code asserts
Using inline ASSERTs certainly achieves some of the aims of UnitTesting. However, as part of the main code, they will not be tested where the test suite used does not have coverage. This will be true both in terms of lines touched, and parameters used. Such ASSERTs will also often make an identical test repeatedly.