Home About News Contact

wxTestRunner: a CppUnit (C++) Test Runner for wxWidgets


Title wxTestRunner
Author Anthon Pang and Baptiste Lepilleur
Requirements CppUnit 1.10.2 (or later) and wxWidgets 2.5.2
Version N/A
Released July 17, 2004
Status Submitted


wxTestRunner rounds out CppUnit's complement of GUI test runners. Like the Qt (Trolltech) test runner, the wxWidgets port lacks some of the features found in the MFC variants (e.g., auto-run).


  • The idea for green and red bars comes from JUnit and is described in Kent Beck's book on TDD, "Test-Driven Development: By Example".
  • The wxTestRunner must be a static instance because the main "dialog" is implemented as a non-modal wxFrame, and run() returns before the window is closed. This is specific to the wxWidgets implementation of the test runner. (See Example below.)
  • A common problem when integrating 3rd-party libraries (built from source) is conflicting compiler and/or linker flags.
  • Tested with Borland C++ Builder 6 (Update 4) and Microsoft Visual C++ 7 (from Visual Studio .net).
  • wxWindows was renamed wxWidgets on February 20, 2004.


Browse the test hierarchy to select which tests to run:


A green bar indicates the code passes all the selected tests:

[Green Bar]

A red bar condition means there are one or more broken tests:

[Red Bar]


// wxTest.cpp

#include <wx/wxprec.h>

#ifdef __BORLANDC__
#  pragma hdrstop

#ifndef WX_PRECOMP
#  include <wx/wx.h>

#include <cppunit/ui/wx/WxTestRunner.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

void RunTests(void)
    static CPPUNIT_NS::WxTestRunner runner;

As a guide, we offer a working wxTestRunner example (pulled from our framework) that shows the integration of CppUnit and wxTestRunner. The provided Makefiles (for Linux and Windows) will generate executables differing only in the test driver: console output vs. wxWidgets-based GUI.

Download: wxTestRunner Example (.zip)