= How to build QtTestRunner with Qt 4.0 and Eclipse =

These instructions describe how to build QtTestRunner with Qt 4.0, Eclipse 3.1.1 and CDT 3.0.1 under Windows XP and MinGW. Similar steps should also work for WinXP/Cygwin or Linux, although I haven't tested it.

As a pre-requisite, you will need to have CppUnit compiled as a shared library. If you haven't yet compiled it, you may follow these step by step instructions: CppUnitWithEclipse.

== Installing Qt 4.0 ==

Go to Trolltech's website and download the Qt installation file - e.g.: qt-win-opensource-4.0.1-mingw.exe. Run it and follow the wizard. From now on we will refer to Qt's top installation directory as $Qt.
IMPORTANT: after installation it will still be necessary to execute $Qt/4.0.1/configure.exe.

== Upgrading QtTestRunner source to Qt 4 ==

The Qt``Test``Runner source code that comes with Cpp``Unit was written for Qt2 and is not compatible with Qt4 (the backwards compatibility was broken between Qt3 and Qt4).
Download the following package instead: attachment:QtTestRunner_Qt4.zip. The file changes.txt in the package describes the applied corrections to upgrade to Qt4.

== Compiling the library ==

Create a new Managed Make C++ Project in Eclipse to generate a shared library.

Import to the project all the extracted source files in the downloaded package.

In the project properties configuration dialog (Alt + Enter) edit the following fields:

1. Define the variables QT3_SUPPORT and CPPUNIT_DLL:

attachment:screenshot1.png

2. Add the following directories to the include path:
($Cpp``Unit and $Qt refer to your top level installation directories of Cpp``Unit and Qt)

 * $Cpp``Unit/include
 * $Qt/include
 * $Qt/include/Qt3``Support
 * $Qt/include/Qt``Core
 * $Qt/include/Qt``Gui

attachment:screenshot2.png

3. Include the following shared libraries:

 * Cpp``Unit.dll
 * Qt3``Support4.dll
 * Qt``Core4.dll
 * Qt``Gui4.dll

attachment:screenshot3.png

4. Build the project (Ctrl + B).

== Compile and test a sample test suite ==

Create a new Managed Make C++ Project to generate an executable.

Import the following source files to it: attachment:sample_gui.zip.

In the project properties configuration dialog (Alt + Enter) edit the following fields:

1. Define the variable CPPUNIT_DLL.

2. Add the following directories to the include path:

 * $Cpp``Unit/include
 * $Qt/include
 * $Qt/include/Qt``Gui

3. Include the following libraries:

 * Cpp``Unit.dll
 * Qt``Test``Runner.dll (just created)
 * Qt``Gui4.dll

4. Build the project.

By running the executable you'll find out that all tests will pass. You may now play around and introduce errors in the Complex class methods to see Cpp``Unit's diagnostic error messages when a test fails.
attachment:screenshot4.png

Note: linking with static libraries will not work! If you manage to link with static libraries please update this wiki (the shared library was OK for me, so I didn't bother to investigate any further :-) ).
