|
Packit Service |
e31359 |
Frequently Asked Questions: See doc/FAQ
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
At the current time, the only supported WIN32 platform is
|
|
Packit Service |
e31359 |
Microsoft Visual C++. You must have VC++ 6.0 at least.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Quick Steps to compile & run a sample using the GUI TestRunner:
|
|
Packit Service |
e31359 |
- Open examples/examples.dsw in VC++ (contains all the samples).
|
|
Packit Service |
e31359 |
VC7 will ask you if you want to convert, anwser 'yes to all'.
|
|
Packit Service |
e31359 |
- Make HostApp the Active project
|
|
Packit Service |
e31359 |
- Compile
|
|
Packit Service |
e31359 |
- Run the project
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Project build Target:
|
|
Packit Service |
e31359 |
---------------------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Framework & tools:
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* cppunit (cppunit.lib) : unit testing framework library, the one you use
|
|
Packit Service |
e31359 |
to write unit tests.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* cppunit_dll(cppunit_dll.dll/lib) : same as above, but build as a DLL.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* DllPlugInTester(DllPlugInTester.exe) : test plug-in runner executable.
|
|
Packit Service |
e31359 |
Use this to test DLL in your post-build step, or debug them.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* TestRunner (testrunner.dll) : a MFC extension DLL to run and browser unit
|
|
Packit Service |
e31359 |
tests from a GUI.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* TestPlugInRunner : (Warning: experimental) a VC++
|
|
Packit Service |
e31359 |
application to run test plug-in. A test plug-in is a DLL that publish a
|
|
Packit Service |
e31359 |
specified interface. This application is still incomplete (the auto-reload
|
|
Packit Service |
e31359 |
feature is missing).
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
All libraries are placed in the lib/ directory.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Examples:
|
|
Packit Service |
e31359 |
---------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* CppUnitTestMain : the actual test suite use to test CppUnit. Use a
|
|
Packit Service |
e31359 |
TextTestRunner, and post-build testing with CompilterOutputter. Configuration
|
|
Packit Service |
e31359 |
to link against cppunit static library and cppunit dll library.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* CppUnitTestApp : contains the same test suite as CppUnitTestMain, but
|
|
Packit Service |
e31359 |
run them using the MFC TestRunner.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* hierarchy : a sample demonstrating how to sublcass test (you might rather
|
|
Packit Service |
e31359 |
want to use HelperMacros.h and the CPPUNIT_TEST_SUB_SUITE macro which does
|
|
Packit Service |
e31359 |
it in a 'cleaner' way. That sample has not been updated for a long time).
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* HostApp : a sample using the MFC TestRunner demonstrating different test
|
|
Packit Service |
e31359 |
failure. Also demonstrates the MFC Unicode TestRunner.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* Money : an example that come along with the Money article of the
|
|
Packit Service |
e31359 |
documentation. Probably what you want to look at if you are a newbie.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Configuration:
|
|
Packit Service |
e31359 |
--------------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
CppUnit and TestRunner comes with 3 configurations.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* Release (): Multihtreaded DLL, release mode
|
|
Packit Service |
e31359 |
* Debug (d): Debug Multithreaded DLL, debug mode
|
|
Packit Service |
e31359 |
* Unicode Release (u): Unicode Multihtreaded DLL, release mode
|
|
Packit Service |
e31359 |
* Unicode Debug (ud): Unicode Debug Multithreaded DLL, debug mode
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
For CppUnit, when building as dll, "dll" is appended to the 'suffix'.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
The letters enclosed in brackets indicates the suffix added to
|
|
Packit Service |
e31359 |
the library name. For example, the debug configuration cppunit static library
|
|
Packit Service |
e31359 |
name is cppunitd.lib. The debug configuration cppunit dll name is cppunitd_dll.lib.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Building:
|
|
Packit Service |
e31359 |
---------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* Open the src/CppUnitLibraries.dsw workspace in VC++.
|
|
Packit Service |
e31359 |
* In the 'Build' menu, select 'Batch Build...'
|
|
Packit Service |
e31359 |
* In the batch build dialog, select all projects and press the build button.
|
|
Packit Service |
e31359 |
* The resulting libraries can be found in the lib/ directory.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Testing:
|
|
Packit Service |
e31359 |
--------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* Open the workspace examples/Examples.dsw.
|
|
Packit Service |
e31359 |
* Make CppUnitTestApp the active project.
|
|
Packit Service |
e31359 |
* Select the configuration you build the library for.
|
|
Packit Service |
e31359 |
* Compile and run the project. The TestRunner GUI should appear.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Libraries:
|
|
Packit Service |
e31359 |
----------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
All the compiled libraries and DLL can be found in the 'lib' directory.
|
|
Packit Service |
e31359 |
Most libraries can be build from src/CppUnitLibraries.dsw workspace.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
lib\:
|
|
Packit Service |
e31359 |
cppunit.lib : CppUnit static library "Multithreaded DLL"
|
|
Packit Service |
e31359 |
cppunitd.lib : CppUnit static library "Debug Multithreaded DLL"
|
|
Packit Service |
e31359 |
cppunit_dll.dll : CppUnit dynamic library (DLL) "Multithreaded DLL"
|
|
Packit Service |
e31359 |
cppunit_dll.lib : CppUnit dynamic import library "Multithreaded DLL"
|
|
Packit Service |
e31359 |
cppunitd_dll.dll : CppUnit dynamic library (DLL) "Debug Multithreaded DLL"
|
|
Packit Service |
e31359 |
cppunitd_dll.lib : CppUnit dynamic import library "Debug Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunner.dll : MFC TestRunner dynamic library (DLL) "Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunner.lib : MFC TestRunner import library "Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunnerd.dll : MFC TestRunner dynamic library (DLL) "Debug Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunnerd.lib : MFC TestRunner import library "Debug Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunneru.dll : MFC Unicode TestRunner dynamic library (DLL) "Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunneru.lib : MFC Unicode TestRunner import library "Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunnerud.dll : MFC Unicode TestRunner dynamic library (DLL) "Debug Multithreaded DLL"
|
|
Packit Service |
e31359 |
testrunnerud.lib : MFC Unicode TestRunner import library "Debug Multithreaded DLL"
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Notes that when you are using CppUnit DLL (cppunit*_dll.dll), you must link
|
|
Packit Service |
e31359 |
against the associated import library and define the pre-processor symbol
|
|
Packit Service |
e31359 |
CPPUNIT_DLL in your project.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Tools:
|
|
Packit Service |
e31359 |
------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
CppUnit provides a generic test runner for test plug-in: DllPlugInTester.
|
|
Packit Service |
e31359 |
It can be found in the lib/ directory. It requires cppunit*_dll.dll
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
lib/:
|
|
Packit Service |
e31359 |
DllPlugInTester_dll.exe : test plug-in runner, "Multithreaded DLL", cppunit_dll.dll
|
|
Packit Service |
e31359 |
DllPlugInTesterd_dll.exe : test plug-in runner, "Debug Multithreaded DLL", cppunitd_dll.dll
|
|
Packit Service |
e31359 |
DllPlugInTester.exe : test plug-in runner, "Multithreaded DLL", static link cppunit.lib
|
|
Packit Service |
e31359 |
DllPlugInTesterd.exe : test plug-in runner, "Debug Multithreaded DLL", static link cppunitd.lib
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Notes that the DllPlugInTester(d).exe version of this tools does not allow
|
|
Packit Service |
e31359 |
to use the automatic test registration that comes along with test plug-in.
|
|
Packit Service |
e31359 |
You probably don't want to use them unless you really know what you are doing.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Using CppUnit:
|
|
Packit Service |
e31359 |
--------------
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* Writing unit tests:
|
|
Packit Service |
e31359 |
To write unit tests, you need to link against cppunitXX.lib, where
|
|
Packit Service |
e31359 |
XX is the chosen configuration suffix letters.
|
|
Packit Service |
e31359 |
CppUnit include directory must be in the include search path.
|
|
Packit Service |
e31359 |
You can do that by adding the include directory in
|
|
Packit Service |
e31359 |
Project Settings/C++/Preprocessor/Additional include directories,
|
|
Packit Service |
e31359 |
or Tools/Options/Directories/Include.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Quick steps:
|
|
Packit Service |
e31359 |
- link lib/cppunitXX.lib
|
|
Packit Service |
e31359 |
- include/ must be in the include search path
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
* Using the TestRunner GUI:
|
|
Packit Service |
e31359 |
To use the test runner GUI you need to link against testrunnerXX.lib
|
|
Packit Service |
e31359 |
and cppunitXX.lib, where XX is the chosen configuration suffix
|
|
Packit Service |
e31359 |
letters. testrunner.dll must be in the path when your program is
|
|
Packit Service |
e31359 |
run (the Debug/Release directory, your project dsp directory, or
|
|
Packit Service |
e31359 |
in a directory specified in the PATH environment variable).
|
|
Packit Service |
e31359 |
One of the easiest way to do that is to either add a post-build
|
|
Packit Service |
e31359 |
command or add the testrunner.dll which is in the lib/ directory
|
|
Packit Service |
e31359 |
to your project and define a custom build step that copy the
|
|
Packit Service |
e31359 |
dll to your "Intermediate" directory (Debug or Release usually).
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Since the TestRunner GUI is a MFC extension DLL, it can access
|
|
Packit Service |
e31359 |
the CWinApp of the using application. Settings are stored using
|
|
Packit Service |
e31359 |
the application registry key. That means that "most recently used
|
|
Packit Service |
e31359 |
test" settings are different for each application.
|
|
Packit Service |
e31359 |
|
|
Packit Service |
e31359 |
Quick steps:
|
|
Packit Service |
e31359 |
- link lib/cppunitXX.lib and lib/testrunnerXX.lib
|
|
Packit Service |
e31359 |
- include/ must be in the include search path
|
|
Packit Service |
e31359 |
- lib/testrunnerXX.dll must be available to run your project
|