ExtendedTextTestRunner
Philippe FREMY <[email protected]> Fri, 17 Jan 2003 11:17:21 +0100
| Newsgroups | gmane.comp.lib.cppunit.devel |
|---|---|
| Message-ID | <191CBBF91062D411855D00D0B76F1C300113F798@PROXIMA> |
Hi,
For my personal need, I have extended the CppUnit::TextUi::TestRunner. The
extension is very simple, the goal for me was just to be able to provide my
own outputter and progress listener.
See:
--- ExtendedTestRunner.h
namespace CppUnit {
class ExtendedTestRunner : public TextUi::TestRunner {
public:
ExtendedTestRunner( Outputter *outputter =NULL, TestListener *
progressListener =NULL)
: TextUi::TestRunner( outputter), m_progressListener(
progressListener) {
if (m_progressListener == NULL) {
m_progressListener = new TextTestProgressListener();
}
}
virtual bool runTest( Test *test,
bool doPrintProgress );
virtual void setTestProgressListener( TestListener * listener) {
delete m_progressListener;
m_progressListener = listener;
}
virtual void setTestResultCollector( TestResultCollector * result) {
delete m_result;
m_result = result;
}
protected:
TestListener * m_progressListener;
};
}; // CppUnit
------- ExtendedTestRunner.cpp
namespace CppUnit {
bool
ExtendedTestRunner::runTest( Test *test,
bool doPrintProgress )
{
if ( doPrintProgress )
m_eventManager->addListener( m_progressListener );
test->run( m_eventManager );
if ( doPrintProgress )
m_eventManager->removeListener( m_progressListener );
return m_result->wasSuccessful();
}
};
------------------------------
I don't remember if adding a virtual method and a new protected member
breaks binary compatbility. If not, I suggest to add my method directly the
TextUi::TestRunner . Else, I would be happy to see this small class included
directly into CppUnit.
I have other personal improvements, but I won't talk about them until they
are ready.
regards,
Philippe
-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en