diff options
| author | Robert Collins <robertc@robertcollins.net> | 2009-10-03 23:33:53 +1000 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2009-10-03 23:33:53 +1000 |
| commit | 493a10dc9146e4ea9dd98ca69fe658a8139f35fc (patch) | |
| tree | 6b8b21aa693bd783626ca3cec772fd1f987b678c /c++/README | |
| parent | a0fece2a82603e4cc7037313795b08e937e8a758 (diff) | |
| download | subunit-git-493a10dc9146e4ea9dd98ca69fe658a8139f35fc.tar.gz | |
Move the C++ Listener from a patch against cppunit to a usable external module for cppunit.
Diffstat (limited to 'c++/README')
| -rw-r--r-- | c++/README | 59 |
1 files changed, 30 insertions, 29 deletions
@@ -18,32 +18,33 @@ # Currently there are no native C++ bindings for subunit. However the C library -can be used from C++ safely. There is also a patch for cppunit -(http://cppunit.sourceforge.net/) to enable reporting via subunit -(cppunit-subunit-1.10.2.patch). - -To use the patch, apply it and rebuild your cppunit. Then in your main do -{ - // Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // Add a listener that collects test result - // so we can get the overall status. - // note this isn't needed for subunit... - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // Add a listener that print test activity in subunit format. - CPPUNIT_NS::SubunitTestProgressListener progress; - controller.addListener( &progress ); - - // Add the top suite to the test runner - CPPUNIT_NS::TestRunner runner; - runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); - runner.run( controller ); - - return result.wasSuccessful() ? 0 : 1; -} - - -See the c/README for documentation on the C bindings for subunit. +can be used from C++ safely. A CPPUnit listener is built as part of Subunit to +allow CPPUnit users to simply get Subunit output. + +To use the listener, use pkg-config (or your preferred replacement) to get the +cflags and link settings from libcppunit_subunit.pc. + +In your test driver main, use SubunitTestProgressListener, as shown in this +example main:: + + { + // Create the event manager and test controller + CPPUNIT_NS::TestResult controller; + + // Add a listener that collects test result + // so we can get the overall status. + // note this isn't needed for subunit... + CPPUNIT_NS::TestResultCollector result; + controller.addListener( &result ); + + // Add a listener that print test activity in subunit format. + CPPUNIT_NS::SubunitTestProgressListener progress; + controller.addListener( &progress ); + + // Add the top suite to the test runner + CPPUNIT_NS::TestRunner runner; + runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); + runner.run( controller ); + + return result.wasSuccessful() ? 0 : 1; + } |
