
At 05:57 PM 1/11/2005, Noel Llopis wrote:
That's one of the areas that I think CppUnit did a really good job. This is how one possible main looks for them:
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 the top suite to the test runner CPPUNIT_NS::TestRunner runner; runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); runner.run( controller );
// Print test in a compiler compatible format. CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); outputter.write();
return result.wasSuccessful() ? 0 : 1; }
It's very configurable, and it can be called from anywhere. It might be a
bit long, but you're only going to write it once per test project, so it's not a big deal at all.
I beg to differ. Having to supply all that boilerplate would be a huge disincentive. One of the really nice things about Boost.Test is how easy it is to set up a new test project. It really encourages setting up test programs not just for large important projects, but also for every little project that come along. The low entry cost of starting a Boost.Test project is also an incentive when trying to convince more programmers to get into the habit of always writing tests. If Gennadiy can provide addition functionality making it easier for those needing more startup/shutdown control, great. But it shouldn't come at any cost to those who don't need that functionality. --Beman