Re: [Cppunit-devel] Running subset of CPPUnit tests in non-interactive mode
Brought to you by:
blep
|
From: <vri...@us...> - 2006-01-01 12:58:56
|
> Anyone tried to run subset of testcases within a test-suite in =
non-interactive mode? Any suggestions?
Some methods take a "test path" argument, you can put "RPTest" or =
"RPTest::testConnection" to specify which tests you want to run.
1) The "cppunittest" example shows you how to use a test path specified =
on the command line.
Look at cppunit/examples/cppunittest/CppUnitTestMain.cpp
2) The simpliest way to run a single test is to use a TextTestRunner, =
and to pass the test path to the method run() :
CPPUNIT_NS::Test* suite =3D =
CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
CPPUNIT_NS::TextTestRunner runner;
runner.addTest(suite);
runner.run("RPTest::testConnection");
But this is not very user-friendly, because it only prints dots as the =
tests are run. Anyway if you want to run only one test, this is not a =
problem.
3) A better way to run multiple tests is to use a =
BriefTestProgressListener : while the tests are running, it prints the =
name of the test and the result.
Here is an example, derived from cppunit/examples/simple/Main.cpp
CPPUNIT_NS::Test* suite =3D =
CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
CPPUNIT_NS::TestResult result;
CPPUNIT_NS::TestResultCollector collector;
result.addListener(&collector);
CPPUNIT_NS::BriefTestProgressListener brief;
result.addListener(&brief); =20
CPPUNIT_NS::TestRunner runner;
runner.addTest(suite);
runner.run(result, "RPTest");
CPPUNIT_NS::CompilerOutputter outputter(&collector, =
CPPUNIT_NS::stdCOut());
outputter.write();=20
Happy New Year.
Vincent.
|