+1  A: 

We use cppunit with netbeans, and put all test code in separate projects (eg: jramessage library is tested by jramessage_test console application, which links to cppunit).

These command line test applications can then be easily run from build scripts (we don't have a global makefile; instead we have a top level build script that calls 'make' on each individual project, and runs unit tests as appropriate).

I think putting the test code in the same project would clutter things up too much, and would require your shipping application to link to cppunit (which isn't really desirable).

henryl