From 87e5cf8f526380c40f63208c6c9e785f73d327b7 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Wed, 17 Apr 2002 21:27:28 +0000 Subject: Bumped version to 1. bumped version to 1.9.3 * FAQ: added question about 4786 warning on VC++. * NEWS: updated. * contrib/msvc/readme.txt: moved to contrib/readme.txt. * contrib/xml-xsl/report.xsl: added XML style sheet contributed by 'cuppa' project team (http://sourceforge.jp/projects/cuppa/) * examples/cppunittest/TestResultTest.h: * examples/cppunittest/TestResultTest.cpp: added tests for startTestRun()/endTestRun(). * examples/simple/*: added. A simple example. * include/cppunit/BriefTestProgressListener.h: * src/cppunit/BriefTestProgressListener.cpp: added. Verbose progess listener that print the test name before running the test. * include/cppunit/TestListener.h: added startTestRun()/endTestRun(). * include/cppunit/TestResult.h: * src/cppunit/TestResult.cpp: added runTest(), to be called to run a test by test runner. * src/cppunit/TextTestRunner.cpp: * src/cppunit/TestRunner.cpp: updated to use TestResult::runTest(). * include/cppunit/plugin/PlugInManager.h: * src/cppunit/PlugInManager.cpp: added. Managers for all loaded plug-ins. * include/cppunit/plugin/TestPlugInDefaultImpl.h: * src/cppunit/TestPlugInDefaultImpl.cpp: renamed TestPlugInAdapter. All implementations are empty. * include/cppunit/plugin/TestPlugInSuite.h: removed. * src/cppunit/TestPlugInSuite.cpp: removed. Replaced by PlugInManager. * include/cppunit/plugin/TestPlugIn.h: rewrote the plug-in interface to provide more versatility. updated macros to match new interface. * include/cppunit/extensions/TestFactoryRegistry.h: * include/cppunit/extensions/TestFactoryRegistry.cpp: Added unregisterFactory(). Added convenience method addRegistry(). Rewrote registry life cycle management. AutoRegisterSuite can now detect that the registry has been destroy and not call to it to unregister its test factory. * include/cppunit/extensions/AutoRegisterTest.h: on destruction, the registered factory is unregistered from the registry. * include/cppunit/extensions/HelperMacros.h: added macros CPPUNIT_REGISTRY_ADD_TO_DEFAULT and CPPUNIT_REGISTRY_ADD to help build test suite hierarchy. * src/cppunit/msvc/DllPlugInTester/*: moved to src/cppunit/DllPlugInTester/. * src/cppunit/DllPlugInTester/DllPlugInTester.cpp: removed UNICODE stuffs. Use the PlugInManager instead of PlugInTestSuite. Simplified: only one test on command line, but many DLL can be specified. Added configurations to link against cppunit dll, those are now the default configuration (static linking don't make much sense for plug-in). --- include/cppunit/plugin/TestPlugIn.h | 84 ++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 29 deletions(-) (limited to 'include/cppunit/plugin/TestPlugIn.h') diff --git a/include/cppunit/plugin/TestPlugIn.h b/include/cppunit/plugin/TestPlugIn.h index 02facd0..0847928 100644 --- a/include/cppunit/plugin/TestPlugIn.h +++ b/include/cppunit/plugin/TestPlugIn.h @@ -5,9 +5,13 @@ #if !defined(CPPUNIT_NO_TESTPLUGIN) +#include + namespace CppUnit { class Test; +class TestFactoryRegistry; +class TestResult; } /*! \file @@ -19,6 +23,14 @@ class Test; * * This class define the interface implemented by test plug-in. A pointer to that * interface is returned by the function exported by the test plug-in. + * + * Plug-in are loaded/unloaded by PlugInManager. When a plug-in is loaded, + * initialize() is called. Before unloading the plug-in, the PlugInManager + * call uninitialize(). + * + * addListener() and removeListener() are called respectively before and after + * the test run. + * * \see CPPUNIT_PLUGIN_IMPLEMENT, CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL * \see TestPlugInDefaultImpl. */ @@ -26,23 +38,44 @@ struct CppUnitTestPlugIn { /*! Called just after loading the dynamic library. * - * Initializes the plug-in. + * Override this method to add additional suite to the registry, though this + * is preferably done using the macros (CPPUNIT_TEST_SUITE_REGISTRATION...). + * If you are creating a custom listener to extends the plug-in runner, + * you can use this to configure the listener using the \a parameters. + * + * You could also use the parameters to specify some global parameter, such + * as test datas location, database name... + * + * N.B.: Parameters interface is not define yet, and the plug-in runner does + * not yet support plug-in parameter. + */ + virtual void initialize( CppUnit::TestFactoryRegistry *registry, + const CppUnit::Parameters ¶meters ) =0; + + /*! Gives a chance to the plug-in to register TestListener. + * + * Override this method to add a TestListener for the test run. This is useful + * if you are writing a custom TestListener, but also if you need to + * setUp some global resource: listen to TestListener::startTestRun(), + * and TestListener::endTestRun(). */ - virtual void initialize() = 0; + virtual void addListener( CppUnit::TestResult *eventManager ) =0; - /*! Returns the root test of the plug-in. + /*! Gives a chance to the plug-in to remove its registered TestListener. * - * Caller does not assume ownership of the test. - * \return Pointer on a Test. Must never be \c NULL. The caller does not assume - * ownership of the returned Test. The Test must remain valid until - * uninitialize() is called. + * Override this method to remove a TestListener that has been added. */ - virtual CppUnit::Test *getTestSuite() =0; + virtual void removeListener( CppUnit::TestResult *eventManager ) =0; /*! Called just before unloading the dynamic library. - * Unitializes the plug-in. + * + * Override this method to unregister test factory added in initialize(). + * This is necessary to keep the TestFactoryRegistry 'clean'. When + * the plug-in is unloaded from memory, the TestFactoryRegistry will hold + * reference on test that are no longer available if they are not + * unregistered. */ - virtual void uninitialize() = 0; + virtual void uninitialize( CppUnit::TestFactoryRegistry *registry ) =0; }; @@ -60,7 +93,7 @@ struct CppUnitTestPlugIn /*! Type of the function exported by a plug-in. * \ingroup WritingTestPlugIn */ -typedef CppUnitTestPlugIn *(*CppUnitTestPlugInSignature)(); +typedef CppUnitTestPlugIn *(*TestPlugInSignature)(); /*! Implements the function exported by the test plug-in @@ -76,7 +109,7 @@ typedef CppUnitTestPlugIn *(*CppUnitTestPlugInSignature)(); // Note: This include should remain after definition of CppUnitTestPlugIn -#include +#include /*! \def CPPUNIT_PLUGIN_IMPLEMENT_MAIN() @@ -116,8 +149,6 @@ typedef CppUnitTestPlugIn *(*CppUnitTestPlugInSignature)(); } \ typedef char __CppUnitPlugInImplementMainDummyTypeDef -// (void)argc; (void)argv; \ - // Other #else // other platforms don't require anything specifics @@ -128,24 +159,19 @@ typedef CppUnitTestPlugIn *(*CppUnitTestPlugInSignature)(); /*! Implements and exports the test plug-in interface. * \ingroup WritingTestPlugIn * - * This macro creates a subclass of CppUnitTestPlugInDefaultImpl to specify set - * the name of the suite returned by CppUnitTestPlugIn::getTestSuite(), exports - * the test plug-in function using the subclass, and implements the 'main' - * function for the plug-in using CPPUNIT_PLUGIN_IMPLEMENT_MAIN(). + * This macro exports the test plug-in function using the subclass, + * and implements the 'main' function for the plug-in using + * CPPUNIT_PLUGIN_IMPLEMENT_MAIN(). + * + * When using this macro, CppUnit must be linked as a DLL (shared library). + * Otherwise, tests registered to the TestFactoryRegistry in the DLL will + * not be visible to the DllPlugInTester. * - * \see CppUnitTestPlugIn, CppUnitTestPlugInDefaultImpl + * \see CppUnitTestPlugIn * \see CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL(), CPPUNIT_PLUGIN_IMPLEMENT_MAIN(). */ -#define CPPUNIT_PLUGIN_IMPLEMENT( suiteName ) \ - class __CppUnitTestPlugInNamedDefaultImpl : public CppUnit::TestPlugInDefaultImpl \ - { \ - virtual std::string getSuiteName() \ - { \ - return suiteName; \ - } \ - }; \ - \ - CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( __CppUnitTestPlugInNamedDefaultImpl ); \ +#define CPPUNIT_PLUGIN_IMPLEMENT() \ + CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CppUnit::TestPlugInAdapter ); \ CPPUNIT_PLUGIN_IMPLEMENT_MAIN() -- cgit v1.2.1