Previous to cfix 1.5, the framework only supported tests compiled and linked into a DLL file. While such DLL-based tests remain the preferred and most flexible choice, cfix 1.5 has added support for EXE-based tests.
In cases where cleanly isolating test code from application code is not possible or implementing tests in a DLL is not feasible for other reasons, cfix can be directed to execute tests embedded into an EXE file.
When using EXE targets, please note the following:
- The project's main/WinMain routine can remain as is and will not be executed by cfix.
- CRT initialization is conducted as normal. In particular, this means that you can rely on constructors of global objects to have run.
- To avoid tests from being included in shipping code, it is usually advisable to make use of preprocessor #ifdefs or the "Exclude from build" feature offered by Visual Studio.
- Due to limitations of downlevel linker versions, this feature requires Visual Studio 2005 (cl 14.0/link 8.0) or better.
Because the application's main/WinMain routine is not changed, launching the EXE will cause normal program behavior. To run the unit tests, launch the EXE indirectly using cfix32 (for 32 bit programs) or cfix64 (for 64 bit programs) while specifying the -exe command line switch -- e.g.: cfix32 -exe app.exe. cfix32/cfix64 will then spawn app.exe as child process, causing all unit tests to be run.