~launchpad/subunit/launchpad-ppa-hardy

« back to all changes in this revision

Viewing changes to c++/README

  • Committer: Bazaar Package Importer
  • Author(s): Robert Collins
  • Date: 2009-12-20 16:33:29 UTC
  • mfrom: (1.1.3 upstream) (3.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091220163329-o60chash60h5zzj2
Tags: 0.0.4-4
Upstream bugfix for FTBFS on test_child.c.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#
19
19
 
20
20
Currently there are no native C++ bindings for subunit. However the C library
21
 
can be used from C++ safely. There is also a patch for cppunit
22
 
(http://cppunit.sourceforge.net/) to enable reporting via subunit
23
 
(cppunit-subunit-1.10.2.patch).
24
 
 
25
 
To use the patch, apply it and rebuild your cppunit. Then in your main do
26
 
{
27
 
  // Create the event manager and test controller
28
 
  CPPUNIT_NS::TestResult controller;
29
 
 
30
 
  // Add a listener that collects test result
31
 
  // so we can get the overall status.
32
 
  // note this isn't needed for subunit...
33
 
  CPPUNIT_NS::TestResultCollector result;
34
 
  controller.addListener( &result );
35
 
 
36
 
  // Add a listener that print test activity in subunit format.
37
 
  CPPUNIT_NS::SubunitTestProgressListener progress;
38
 
  controller.addListener( &progress );
39
 
 
40
 
  // Add the top suite to the test runner
41
 
  CPPUNIT_NS::TestRunner runner;
42
 
  runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
43
 
  runner.run( controller );
44
 
 
45
 
  return result.wasSuccessful() ? 0 : 1;
46
 
}
47
 
 
48
 
 
49
 
See the c/README for documentation on the C bindings for subunit.
 
21
can be used from C++ safely. A CPPUnit listener is built as part of Subunit to
 
22
allow CPPUnit users to simply get Subunit output.
 
23
 
 
24
To use the listener, use pkg-config (or your preferred replacement) to get the
 
25
cflags and link settings from libcppunit_subunit.pc.
 
26
 
 
27
In your test driver main, use SubunitTestProgressListener, as shown in this
 
28
example main::
 
29
 
 
30
  {
 
31
    // Create the event manager and test controller
 
32
    CPPUNIT_NS::TestResult controller;
 
33
  
 
34
    // Add a listener that collects test result
 
35
    // so we can get the overall status.
 
36
    // note this isn't needed for subunit...
 
37
    CPPUNIT_NS::TestResultCollector result;
 
38
    controller.addListener( &result );
 
39
  
 
40
    // Add a listener that print test activity in subunit format.
 
41
    CPPUNIT_NS::SubunitTestProgressListener progress;
 
42
    controller.addListener( &progress );
 
43
  
 
44
    // Add the top suite to the test runner
 
45
    CPPUNIT_NS::TestRunner runner;
 
46
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
 
47
    runner.run( controller );
 
48
  
 
49
    return result.wasSuccessful() ? 0 : 1;
 
50
  }