Expanding on Tom Quarendon’s answer to this question, I have used a slight variant of Simon Steele’s response:
- Create a test project (using whatever test framework you like, I use CppUnit).
- In your test_case.cpp,
#include <header/in/source/project.h>
. - In the test project properties:
- In Linker->General, add the source project’s
$(IntDir)
to the Additional Library Directories. - In Linker->Input, add the
.obj
files to the Additional Dependencies.
- In Linker->General, add the source project’s
- Add the dependency from the test project to the source project in Project->Project Dependencies.
Again, the only maintenance overhead is the standard one for unit tests – to create the dependency on the unit(s) you want to test.