Boost logo

Boost :

From: jorg.schaible_at_[hidden]
Date: 2000-01-31 12:25:59

Hi Nico (and all others),

sorry for not posting any additional help to use the test unit. Here come some
additional information.

Basic idea is to support a developer with classes that allow him to write test
cases. A test case should ensure the functionality of his "code unit" and can be
used to ensure it at any time again. The test performs white box testing i.e.
the developer should test all functionality of his unit and ensure the proper

A test case can be written by deriving a class from TestCase. A test case
contains the complete functionality to test the interface of the code unit, each
single test is performed by a separate member function (that starts by convetion
with "test", since Java is able to collect functions of a class by name). Each
instance of the derived test case is able to run one of these test functions. By
providing the c'tor of TestCase with the name of the single test (by convention
the name of the test function) and the address of the member function you may
call the run method to execute the test. Several test case instances can be
collected in the class TestSuite. Such an instance should be created by the
static function "suite" each derived test case should provide.

The test functions uses the assert(ion) functions of the base class Assert of
TestCase to ensure the proper result of the functionality. If the test fails
these assert functions will generate a proper message string and raise an
AssertionFailedError. An instance of the TestResult class (used as argument for
TestCase::run) will collect these exceptions and count them as failures. Other
exceptions will be counted as errors.

The class TestRunner is used to automate this process. It has functions to
register several test suites, create a test result object, and run the tests of
the suite. The TextTestResult is used to show the progress of the tests on the
command line, is able to present the results, and will return an overall status.
The developer just has to create a TestRunner instance, create and add all
suites and run the tests. Normally this will be done in main.

Provided files:
testunit.hpp - Contains the complete code of core system of the JUnit port. Is
located in boost directory.
SimpleTest.hpp and SimpleTest.cpp - Contains the test case and suite for a
simple test of adding double values.
AllTests.cpp - Contains the main function of a test application.

To build the application compile and link the cpp's together. The resulting
application can be started with argument "-all" to start all tests or use
individual test names as arguments.

HTML reference documentation can be generated form the testunit.hpp by using
Doxygen (


P.S. for Nico: Nun ja, klingt wirklich verdächtig deutsch <g>. Ich komme aus
Villingen-Schwenningen (letzteres) im süddeutschen Raum, allgemein bekannt
höchstens durch das Eishockey (Wild Wings) oder Martin Schmitt, den Überflieger
im Skispringen.

---------------------------------------- Message History

From: nicolai.josuttis_at_[hidden] on 29/01/2000 17:09

Please respond to boost_at_[hidden]

To: boost_at_[hidden]; Jorg Schaible/DMGIB/DMG UK/DeuBa
Subject: [boost] Re: Proposal: Test Unit

Hi Jörg,
first thanks for the proposal. A well test duite sounds
very intersting to me.

I tried to understand how the test suite operates.
But at least with my non-knowledge of JUnit and
DejaGNU I could find no easy way to see the
way it works (although, I spent not much time to
find out the details on my own by studying your code).
Is there a general introduction into this test framework
or a HowTo guide?

May be I could answer your questions, then.

Thanks again

P.S. Jörg klingt wie ein deutscher Name.
Kommst Du hier aus Deutschland?

jorg.schaible_at_[hidden] wrote:
> Hi there,
> attached to this mail there is a ported version (from Java to C++) of the core
> system of the JUnit 3.1 test suite of Kent Beck and Erich Gamma. The classes
> allow you to setup easy module tests for your classes and integrate this test
> applciations in an automated test procedure. The JUnit suite normally has also
> GUI version, but since C++ has no standard it is not part of the port. To
> integrate future versions of JUnit I try to stay very close the the original
> Java source although I changed the concept of the TestRunner slightly to
> seperate data and test output and to gain make support from the exit code of a
> test application. Also I dropped some Java only features.
> I am aware that from Michael Feathers exists another port of JUnit, but
> - the version I previously had did not fulfill the Boost standards (e.g. using
> namespace std in the headers)
> - I had to have a portable version
> - I wanted to have a JUnit port added to Boost to have some kind of standard
> - wanted to build automated tests and was not interested in a GUI
> - I needed it now (most common reason <g>)
> Additionally I know also DejaGNU, but I found it very nasty to provide Windows
> development seats with the necessary environment and train the people with
> complete package.
> Concerning the proposal to Boost I am interested in following answers:
> - The original source seperates the classes into different files. Currently
> boost libraries use just one single header in the boost directory. Shoud I
> this single header (yes, the inlines are too big) or separate this classes
> - Should I move the classes in an additional namespace boost::test?
> Awaiting your comments ....
> Regards,
> Jörg
> (See attached file: testunit.hpp)
> Example:
> (See attached file: SimpleTest.hpp)(See attached file: SimpleTest.cpp)(See
> attached file: AllTests.cpp)
> ------------------------------------------------------------------------
> GET A NEXTCARD VISA, in 30 seconds! Get rates
> as low as 0.0% Intro APR and no hidden fees.
> Apply NOW!
> -- Create a poll/survey for your group!
> --
> Name: testunit.hpp
> testunit.hpp Type: unspecified type (application/octet-stream)
> Encoding: base64
> Name: SimpleTest.hpp
> SimpleTest.hpp Type: unspecified type (application/octet-stream)
> Encoding: base64
> Name: SimpleTest.cpp
> SimpleTest.cpp Type: unspecified type (application/octet-stream)
> Encoding: base64
> Name: AllTests.cpp
> AllTests.cpp Type: unspecified type (application/octet-stream)
> Encoding: base64

Nicolai M. Josuttis 
Solutions in Time             mailto:solutions_at_[hidden]
Want to send money instantly to anyone, anywhere, anytime?
You can today at - and we'll give you $20 to try it!  Sign
up today at  It's quick, free, & there's no obligation!
-- Create a poll/survey for your group!

Boost list run by bdawes at, gregod at, cpdaniel at, john at