CppUnit - The Unit Testing Library

CppUnit project page | FAQ

TestPlugIn.h
Go to the documentation of this file.
1#ifndef CPPUNIT_PLUGIN_TESTPLUGIN
2#define CPPUNIT_PLUGIN_TESTPLUGIN
3
4#include <cppunit/Portability.h>
5
6#if !defined(CPPUNIT_NO_TESTPLUGIN)
7
8#include <cppunit/plugin/PlugInParameters.h>
9
10 CPPUNIT_NS_BEGIN
11
12
13class Test;
14class TestFactoryRegistry;
15class TestResult;
16class XmlOutputter;
17
18 CPPUNIT_NS_END
19
22
23
43 struct CPPUNIT_API CppUnitTestPlugIn
44{
58 virtual void initialize( CPPUNIT_NS::TestFactoryRegistry *registry,
59 const CPPUNIT_NS::PlugInParameters &parameters ) =0;
60
68 virtual void addListener( CPPUNIT_NS::TestResult *eventManager ) =0;
69
74 virtual void removeListener( CPPUNIT_NS::TestResult *eventManager ) =0;
75
78 virtual void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter ) =0;
79
84 virtual void removeXmlOutputterHooks() = 0;
85
94 virtual void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry ) =0;
95
96 virtual ~CppUnitTestPlugIn() {}
97};
98
99
100
109#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
110
114 typedef CppUnitTestPlugIn *(*TestPlugInSignature)();
115
116
120#define CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( TestPlugInInterfaceType ) \
121 CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void) \
122 { \
123 static TestPlugInInterfaceType plugIn; \
124 return &plugIn; \
125 } \
126 typedef char __CppUnitPlugInExportFunctionDummyTypeDef // dummy typedef so it can end with ';'
127
128
129// Note: This include should remain after definition of CppUnitTestPlugIn
130#include <cppunit/plugin/TestPlugInDefaultImpl.h>
131
132
140
141// Win32
142#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER)
143#if !defined(APIENTRY)
144#define WIN32_LEAN_AND_MEAN
145#define NOGDI
146#define NOUSER
147#define NOKERNEL
148#define NOSOUND
149#ifndef NOMINMAX
150#define NOMINMAX
151#endif
152#define BLENDFUNCTION void // for mingw & gcc
153#include <windows.h>
154#endif
155#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
156 BOOL APIENTRY DllMain( HANDLE, DWORD, LPVOID ) \
157 { \
158 return TRUE; \
159 } \
160 typedef char __CppUnitPlugInImplementMainDummyTypeDef
161
162// Unix
163#elif defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) || defined(CPPUNIT_HAVE_UNIX_SHL_LOADER)
164#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
165 int main() \
166 { \
167 return 0; \
168 } \
169 typedef char __CppUnitPlugInImplementMainDummyTypeDef
170
171
172// Other
173#else // other platforms don't require anything specifics
174#endif
175
176
177
192#define CPPUNIT_PLUGIN_IMPLEMENT() \
193 CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CPPUNIT_NS::TestPlugInDefaultImpl ); \
194 CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
195
196
197#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
198
199
200#endif // CPPUNIT_PLUGIN_TESTPLUGIN
CPPUNIT_API
#define CPPUNIT_API
Definition CppUnitApi.h:27
PlugInParameters.h
Portability.h
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition Portability.h:105
TestPlugInDefaultImpl.h
TestFactoryRegistry
Registry for TestFactory.
Definition TestFactoryRegistry.h:76
Test
Base class for all test objects.
Definition Test.h:26
TestResult
Manages TestListener.
Definition TestResult.h:48
XmlOutputter
Outputs a TestResultCollector in XML format.
Definition XmlOutputter.h:40
CppUnitTestPlugIn
Test plug-in interface.
Definition TestPlugIn.h:44
CppUnitTestPlugIn::removeXmlOutputterHooks
virtual void removeXmlOutputterHooks()=0
Called when the XmlOutputter is destroyed.
CppUnitTestPlugIn::addXmlOutputterHooks
virtual void addXmlOutputterHooks(CPPUNIT_NS::XmlOutputter *outputter)=0
Provides a way for the plug-in to register some XmlOutputterHook.
CppUnitTestPlugIn::~CppUnitTestPlugIn
virtual ~CppUnitTestPlugIn()
Definition TestPlugIn.h:96
CppUnitTestPlugIn::uninitialize
virtual void uninitialize(CPPUNIT_NS::TestFactoryRegistry *registry)=0
Called just before unloading the dynamic library.
CppUnitTestPlugIn::removeListener
virtual void removeListener(CPPUNIT_NS::TestResult *eventManager)=0
Gives a chance to the plug-in to remove its registered TestListener.
CppUnitTestPlugIn::addListener
virtual void addListener(CPPUNIT_NS::TestResult *eventManager)=0
Gives a chance to the plug-in to register TestListener.
CppUnitTestPlugIn::initialize
virtual void initialize(CPPUNIT_NS::TestFactoryRegistry *registry, const CPPUNIT_NS::PlugInParameters &parameters)=0
Called just after loading the dynamic library.

| Send comments to: CppUnit Developers