For Programmers: Free Programming Magazines  


Home > Archive > Extreme Programming > August 2005 > cppunit - no test will run









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cppunit - no test will run
beta2000@yahoo.com

2005-08-16, 5:04 pm

What's the likely cause of CPPUNIT test program running no tests at
all?

I've written a couple of tests which ran fine before, but after I
played a bit with different TestRunner, then changed back, the original
tests won't run at all. The main() is standard code taken from
examples:

#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
int
main( int argc, char* argv[] )
{
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;

// Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );

// Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener( &progress );

// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.run( controller );

// Print test in a compiler compatible format.
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
outputter.write();

cout << endl << "Press <ENTER> to continue" << endl;
cin.get ();

return result.wasSuccessful() ? 0 : 1;
}

The individual test suites are still in the project and compiled. But
now the output becomes:

OK (0)

Press <ENTER> to continue

Phlip

2005-08-16, 5:04 pm

beta2000 wrote:

> What's the likely cause of CPPUNIT test program running no tests at
> all?


Get one of the sample projects and morph it. Don't start from scratch. I
appreciate the effort of reconstructing CppUnit's (excessive) tangle of
objects, but whatever you missed won't be obvious.

Get a sample project, change its name, and start replacing its tests with
the tests that you need.

Alternately, download one of the CppUnitLite clones that make all this stuff
super-easy. They also support the TestCollector pattern...

TEST(suite, case)
{
CHECK..(..);
}

...which lets you write each case's name only once, not several times.

--
Phlip
[url]http://www.greencheese.org/ZLand[/url] <-- NOT a blog!!!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com