Using CppUnit with Visual Studio
It is a unit testing framework ( a port of JUnit ) for C++ .
The benifit of having a unit testing procedure is that , you can use it either in Test Driven Development or as a standalone test (for testing when needed).
With CPPunit, its very easy to write and run unit tests, as well as integrate the runs with the build process.
Installing CppUnit
The first thing is, there is no installation. The distribution is the source code which must be compiled with the compiler you are using for your C++ work.
Setting up CPPUnit (on windows using Visual Studio):
- Download latest release of CPPUnit
- Extract the zip contents.
- Open the Visual Studio 6 workspace file in the examples directory of the extracted folder.
- If you are using Visual Studio 2005 or 2008, it wont compile out of the box.
Fix For Visual studio 2005 and 2008
Open file MsDevCallerListCtrl.cpp in the folder srcmsvc6testrunner.
Find the following line
#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids |
and change the version("7.0") to:
version("8.0") for VS 2005
version("9.0") for VS 2008
Now do a batch build for all configurations.
Dont worry about errors yet.
Go and look into the lib directory in the cppunit directory.
if you have cppunit.lib, cppunit_dll.lib and cppunit_dll.dll, then you are ready to go.