I am a fan of Boost.Test. As a habbit, I organize my code this way:
// file: Foo.h
Class foo
{
// implementations
};
#ifdef ENABLE_TEST
namespace test_cases
{
BOOST_AUTO_TEST_CASE(foo_tests)
{
// test predicates of class foo
}
} //namespace test_cases
#endif
//end of file Foo.h
With this structure, I can always carry test cases with any class I write, I just need to copy the file around. When I need to test it there is a universal test main.cpp
//File test_main.cpp
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#define ENABLE_TEST
#include "foo.h"
//#include other includes
//End of File test_main
This pattern has helped me to use TDD easily.
The only issue is that test cases are scattered among each header files. Usually I do not know exactly how many test cases/suites are included.
If there is a {--list|-l } option to print a tree of registered test suites and test cases, so that one can quickly look them up here and filter the test cases to be run, it would be a great feature.