wxTestRunner: a CppUnit (C++) Test Runner for wxWidgets
Overview
| 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 |
Synopsis
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).
Notes:
- 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.
Screenshots
Browse the test hierarchy to select which tests to run:
A green bar indicates the code passes all the selected tests:
A red bar condition means there are one or more broken tests:
Example
// wxTest.cpp
#include <wx/wxprec.h>
#ifdef __BORLANDC__
# pragma hdrstop
#endif
#ifndef WX_PRECOMP
# include <wx/wx.h>
#endif
#include <cppunit/ui/wx/WxTestRunner.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
void RunTests(void)
{
static CPPUNIT_NS::WxTestRunner runner;
runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
runner.run(false);
}
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)