diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-13 09:33:50 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-13 09:33:50 +0000 |
| commit | f1bf3276752a10a2cdf4e3cf3087399d199c4566 (patch) | |
| tree | 13dc67edcf465f44b9fe835f5e0b201511774d07 /include/cppunit/ui | |
| parent | 570132ec2707c8bac6c27c758254f05e293fe613 (diff) | |
| download | cppunit-f1bf3276752a10a2cdf4e3cf3087399d199c4566.tar.gz | |
Include/cppunit/ui/text/TestRunner.
include/cppunit/ui/text/TestRunner.h:
* src/cppunit/TextTestRunner.cpp: Renamed TextUi::TestRunner
TextTestRunner and moved it to the CppUnit namespace. Added
a deprecated typedef for compatibility with previous version.
* include/cppunit/ui/text/TextTestRunner.h: added.
* include/cppunit/ui/mfc/TestRunner.h:
* src/cppunit/msvc6/testrunner/TestRunner.cpp: Renamed MfcUi::TestRunner
MfcTestRunner. Added deprecated typedef for compatibility. Renamed
TestRunner.cpp to MfcTestRunner.cpp.
* include/cppunit/ui/mfc/MfcTestRunner.h: added.
* include/cppunit/ui/qt/TestRunner.h:
* src/qttestrunner/TestRunner.cpp: renamed QtUi::TestRunner QtTestRunner
and moved it to CppUnit namespace. Added a deprecated typedef for
compatibility. Renamed TestRunner.cpp to QtTestRunner.cpp.
* include/cppunit/ui/qt/TestRunner.h:
* src/qttestrunner/TestRunner.h: Moved TestRunner to CppUnit namespace
and renamed it QtTestRunner. Added deprecated typedef for compatibility.
* include/cppunit/Asserter.h:
* src/cppunit/Asserter.cpp: changed namespace Asserter to a struct and
made all methods static.
* include/cppunit/extensions/HelperMacros.h:
* include/cppunit/extensions/SourceLine.h:
* include/cppunit/extensions/TestAssert.h:
* include/cppunit/extensions/TestPlugIn.h:
* include/cppunit/Portability.h: changed CPPUNIT_NS(symbol) to a
symbol macro that expand either to CppUnit or nothing. The symbol is
no longer a parameter.
* include/cppunit/portability/CppUnitVector.h:
* include/cppunit/portability/CppUnitDeque.h:
* include/cppunit/portability/CppUnitMap.h: added. STL Wrapper for
compilers that do not support template default argumenent and need
the allocator to be passed when instantiating STL container.
* examples/cppunittest/*.h:
* examples/cppunittest/*.cpp:
* src/msvc6/testrunner/*.h:
* src/msvc6/testrunner/*.cpp:
* src/msvc6/testpluginrunner/*.h:
* src/msvc6/testpluginrunner/*.cpp:
* src/qttestrunner/*.h:
* src/qttestrunner/*.cpp: replaced occurence of CppUnit:: by CPPUNIT_NS.
* src/cppunit/TestSuite.h:
replaced occurence of std::vector by CppUnitVector.
Diffstat (limited to 'include/cppunit/ui')
| -rw-r--r-- | include/cppunit/ui/mfc/Makefile.am | 3 | ||||
| -rw-r--r-- | include/cppunit/ui/mfc/MfcTestRunner.h | 76 | ||||
| -rw-r--r-- | include/cppunit/ui/mfc/TestRunner.h | 79 | ||||
| -rw-r--r-- | include/cppunit/ui/qt/Makefile.am | 1 | ||||
| -rw-r--r-- | include/cppunit/ui/qt/QtTestRunner.h | 85 | ||||
| -rw-r--r-- | include/cppunit/ui/qt/TestRunner.h | 67 | ||||
| -rw-r--r-- | include/cppunit/ui/text/Makefile.am | 3 | ||||
| -rw-r--r-- | include/cppunit/ui/text/TestRunner.h | 88 | ||||
| -rw-r--r-- | include/cppunit/ui/text/TextTestRunner.h | 94 |
9 files changed, 272 insertions, 224 deletions
diff --git a/include/cppunit/ui/mfc/Makefile.am b/include/cppunit/ui/mfc/Makefile.am index 5d84e7b..1ea8b5e 100644 --- a/include/cppunit/ui/mfc/Makefile.am +++ b/include/cppunit/ui/mfc/Makefile.am @@ -1,4 +1,5 @@ libcppunitincludedir = $(includedir)/cppunit/ui/mfc libcppunitinclude_HEADERS = \ - TestRunner.h + TestRunner.h \ + MfcTestRunner.h diff --git a/include/cppunit/ui/mfc/MfcTestRunner.h b/include/cppunit/ui/mfc/MfcTestRunner.h new file mode 100644 index 0000000..6a5f7b7 --- /dev/null +++ b/include/cppunit/ui/mfc/MfcTestRunner.h @@ -0,0 +1,76 @@ +#ifndef CPPUNITUI_MFC_MFCTESTRUNNER_H +#define CPPUNITUI_MFC_MFCTESTRUNNER_H + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include <cppunit/Portability.h> +#include <cppunit/portability/CppUnitVector.h> + +/* Refer to MSDN documentation to know how to write and use MFC extension DLL: + mk:@MSITStore:h:\DevStudio\MSDN\98VSa\1036\vcmfc.chm::/html/_mfcnotes_tn033.htm#_mfcnotes_how_to_write_an_mfc_extension_dll + + This can be found in the index with "mfc extension" + The basic: + Using: + - your application must use MFC DLL + - memory allocation is done using the same heap + - you must define the symbol _AFX_DLL + + Building: + - you must define the symbol _AFX_DLL and _AFX_EXT + - export class using AFX_EXT_CLASS + */ + +CPPUNIT_NS_BEGIN + + class Test; + class TestSuite; + + +/*! \brief MFC test runner. + * \ingroup ExecutingTest + * + * Use this to launch the MFC TestRunner. Usually called from you CWinApp subclass: + * + * \code + * #include <cppunit/ui/mfc/MfcTestRunner.h> + * #include <cppunit/extensions/TestFactoryRegistry.h> + * + * void + * CHostAppApp::RunUnitTests() + * { + * CppUnit::MfcTestRunner runner; + * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); + * + * runner.run(); + * } + * \endcode + * \see CppUnit::TextTestRunner, CppUnit::TestFactoryRegistry. + */ +class AFX_EXT_CLASS MfcTestRunner +{ +public: + MfcTestRunner(); + virtual ~MfcTestRunner(); + + void run(); + + void addTest( Test *test ); + + void addTests( const CppUnitVector<Test *> &tests ); + +protected: + Test *getRootTest(); + + TestSuite *m_suite; + + typedef CppUnitVector<Test *> Tests; + Tests m_tests; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNITUI_MFC_MFCTESTRUNNER_H
\ No newline at end of file diff --git a/include/cppunit/ui/mfc/TestRunner.h b/include/cppunit/ui/mfc/TestRunner.h index 7186bf6..c4d6aff 100644 --- a/include/cppunit/ui/mfc/TestRunner.h +++ b/include/cppunit/ui/mfc/TestRunner.h @@ -1,82 +1,19 @@ #ifndef CPPUNITUI_MFC_TESTRUNNER_H #define CPPUNITUI_MFC_TESTRUNNER_H - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#include <cppunit/Portability.h> -#include <vector> - -/* Refer to MSDN documentation to know how to write and use MFC extension DLL: - mk:@MSITStore:h:\DevStudio\MSDN\98VSa\1036\vcmfc.chm::/html/_mfcnotes_tn033.htm#_mfcnotes_how_to_write_an_mfc_extension_dll - - This can be found in the index with "mfc extension" - The basic: - Using: - - your application must use MFC DLL - - memory allocation is done using the same heap - - you must define the symbol _AFX_DLL - - Building: - - you must define the symbol _AFX_DLL and _AFX_EXT - - export class using AFX_EXT_CLASS - */ +#include <cppunit/ui/mfc/MfcTestRunner.h> CPPUNIT_NS_BEGIN - class Test; - class TestSuite; - +#if defined(CPPUNIT_HAVE_NAMESPACES) namespace MfcUi { - - -/*! \brief MFC test runner. - * \ingroup ExecutingTest - * - * Use this to launch the MFC TestRunner. Usually called from you CWinApp subclass: - * - * \code - * #include <cppunit/ui/mfc/TestRunner.h> - * #include <cppunit/extensions/TestFactoryRegistry.h> - * - * void - * CHostAppApp::RunUnitTests() - * { - * CppUnit::MfcUi::TestRunner runner; - * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); - * - * runner.run(); - * } - * \endcode - * \see CppUnit::TextUi::TestRunner, CppUnit::TestFactoryRegistry. - */ -class AFX_EXT_CLASS TestRunner -{ -public: - TestRunner(); - virtual ~TestRunner(); - - void run(); - - void addTest( Test *test ); - - void addTests( const std::vector<Test *> &tests ); - -protected: - Test *getRootTest(); - - TestSuite *m_suite; - - typedef std::vector<Test *> Tests; - Tests m_tests; -}; - - -} // namespace MfcUi - + /*! Mfc TestRunner (DEPRECATED). + * \deprecated Use CppUnit::MfcTestRunner instead. + */ + typedef CPPUNIT_NS::MfcTestRunner TestRunner; +} +#endif // defined(CPPUNIT_HAVE_NAMESPACES) CPPUNIT_NS_END diff --git a/include/cppunit/ui/qt/Makefile.am b/include/cppunit/ui/qt/Makefile.am index eb213f7..7d4fb46 100644 --- a/include/cppunit/ui/qt/Makefile.am +++ b/include/cppunit/ui/qt/Makefile.am @@ -2,4 +2,5 @@ libcppunitincludedir = $(includedir)/cppunit/ui/qt libcppunitinclude_HEADERS = \ TestRunner.h \ + QtTestRunner.h \ Config.h diff --git a/include/cppunit/ui/qt/QtTestRunner.h b/include/cppunit/ui/qt/QtTestRunner.h new file mode 100644 index 0000000..4b6ab4e --- /dev/null +++ b/include/cppunit/ui/qt/QtTestRunner.h @@ -0,0 +1,85 @@ +// ////////////////////////////////////////////////////////////////////////// +// Header file TestRunner.h for class TestRunner +// (c)Copyright 2000, Baptiste Lepilleur. +// Created: 2001/09/19 +// ////////////////////////////////////////////////////////////////////////// +#ifndef CPPUNIT_QTUI_QTTESTRUNNER_H +#define CPPUNIT_QTUI_QTTESTRUNNER_H + +#include <cppunit/portability/CppUnitVector.h> +#include "Config.h" + +CPPUNIT_NS_BEGIN + + + class Test; + class TestSuite; + + +/*! + * \brief QT test runner. + * \ingroup ExecutingTest + * + * Here is an example of usage: + * \code + * #include <cppunit/extensions/TestFactoryRegistry.h> + * #include <cppunit/ui/qt/TestRunner.h> + * + * [...] + * + * void + * QDepWindow::runTests() + * { + * CppUnit::QtUi::TestRunner runner; + * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); + * runner.run( true ); + * } + * \endcode + * + */ +class QTTESTRUNNER_API QtTestRunner +{ +public: + /*! Constructs a TestRunner object. + */ + QtTestRunner(); + + /*! Destructor. + */ + virtual ~QtTestRunner(); + + void run( bool autoRun =false ); + + void addTest( Test *test ); + +private: + /// Prevents the use of the copy constructor. + QtTestRunner( const QtTestRunner © ); + + /// Prevents the use of the copy operator. + void operator =( const QtTestRunner © ); + + Test *getRootTest(); + +private: + typedef CppUnitVector<Test *> Tests; + Tests *_tests; + + TestSuite *_suite; +}; + + +#if CPPUNIT_HAVE_NAMESPACES + namespace QtUi + { + /*! Qt TestRunner (DEPRECATED). + * \deprecated Use CppUnit::QtTestRunner instead. + */ + typedef CPPUNIT_NS::QtTestRunner TestRunner; + } +#endif + + +CPPUNIT_NS_END + +#endif // CPPUNIT_QTUI_QTTESTRUNNER_H diff --git a/include/cppunit/ui/qt/TestRunner.h b/include/cppunit/ui/qt/TestRunner.h index d58772b..9c53e4b 100644 --- a/include/cppunit/ui/qt/TestRunner.h +++ b/include/cppunit/ui/qt/TestRunner.h @@ -6,71 +6,6 @@ #ifndef CPPUNIT_QTUI_TESTRUNNER_H #define CPPUNIT_QTUI_TESTRUNNER_H -#include <vector> -#include "Config.h" - -CPPUNIT_NS_BEGIN - - - class Test; - class TestSuite; - - namespace QtUi - { - -/*! - * \brief QT test runner. - * \ingroup ExecutingTest - * - * Here is an example of usage: - * \code - * #include <cppunit/extensions/TestFactoryRegistry.h> - * #include <cppunit/ui/qt/TestRunner.h> - * - * [...] - * - * void - * QDepWindow::runTests() - * { - * CppUnit::QtUi::TestRunner runner; - * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); - * runner.run( true ); - * } - * \endcode - * - */ -class QTTESTRUNNER_API TestRunner -{ -public: - /*! Constructs a TestRunner object. - */ - TestRunner(); - - /*! Destructor. - */ - virtual ~TestRunner(); - - void run( bool autoRun =false ); - - void addTest( Test *test ); - -private: - /// Prevents the use of the copy constructor. - TestRunner( const TestRunner © ); - - /// Prevents the use of the copy operator. - void operator =( const TestRunner © ); - - Test *getRootTest(); - -private: - typedef std::vector<Test *> Tests; - Tests *_tests; - - TestSuite *_suite; -}; - - -CPPUNIT_NS_END +#include <cppunit/ui/qt/QtTestRunner.h> #endif // CPPUNIT_QTUI_TESTRUNNER_H diff --git a/include/cppunit/ui/text/Makefile.am b/include/cppunit/ui/text/Makefile.am index 59d5c3e..5f01d81 100644 --- a/include/cppunit/ui/text/Makefile.am +++ b/include/cppunit/ui/text/Makefile.am @@ -1,4 +1,5 @@ libcppunitincludedir = $(includedir)/cppunit/ui/text libcppunitinclude_HEADERS = \ - TestRunner.h + TestRunner.h \ + TextTestRunner.h diff --git a/include/cppunit/ui/text/TestRunner.h b/include/cppunit/ui/text/TestRunner.h index 13bb8b0..c931f66 100644 --- a/include/cppunit/ui/text/TestRunner.h +++ b/include/cppunit/ui/text/TestRunner.h @@ -1,100 +1,18 @@ #ifndef CPPUNIT_UI_TEXT_TESTRUNNER_H #define CPPUNIT_UI_TEXT_TESTRUNNER_H -// Notes: this class is implemented in TextTestRunner.cpp. - -#include <cppunit/Portability.h> -#include <string> -#include <vector> -#include <cppunit/TestRunner.h> +#include <cppunit/ui/text/TextTestRunner.h> CPPUNIT_NS_BEGIN -class Outputter; -class Test; -class TestSuite; -class TextOutputter; -class TestResult; -class TestResultCollector; - -namespace TextUi -{ - /*! * \brief A text mode test runner. - * \ingroup WritingTestResult * \ingroup ExecutingTest - * - * The test runner manage the life cycle of the added tests. - * - * The test runner can run only one of the added tests or all the tests. - * - * TestRunner prints out a trace as the tests are executed followed by a - * summary at the end. The trace and summary print are optional. - * - * Here is an example of use: - * - * \code - * CppUnit::TextUi::TestRunner runner; - * runner.addTest( ExampleTestCase::suite() ); - * runner.run( "", true ); // Run all tests and wait - * \endcode - * - * The trace is printed using a TextTestProgressListener. The summary is printed - * using a TextOutputter. - * - * You can specify an alternate Outputter at construction - * or later with setOutputter(). - * - * After construction, you can register additional TestListener to eventManager(), - * for a custom progress trace, for example. - * - * \code - * CppUnit::TextUi::TestRunner runner; - * runner.addTest( ExampleTestCase::suite() ); - * runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( - * &runner.result(), - * std::cerr ) ); - * MyCustomProgressTestListener progress; - * runner.eventManager().addListener( &progress ); - * runner.run( "", true ); // Run all tests and wait - * \endcode - * - * \see CompilerOutputter, XmlOutputter, TextOutputter. + * \deprecated Use CppUnit::TextUi::TestRunner instead. */ -class CPPUNIT_API TestRunner : public CPPUNIT_NS(TestRunner) -{ -public: - // Work around VC++ bug (class has same name as parent) - typedef CPPUNIT_NS(TestRunner) SuperClass; - - TestRunner( Outputter *outputter =NULL ); - - virtual ~TestRunner(); - - bool run( std::string testPath ="", - bool doWait = false, - bool doPrintResult = true, - bool doPrintProgress = true ); - - void setOutputter( Outputter *outputter ); - - TestResultCollector &result() const; - - TestResult &eventManager() const; - -protected: - virtual void wait( bool doWait ); - virtual void printResult( bool doPrintResult ); - - TestResultCollector *m_result; - TestResult *m_eventManager; - Outputter *m_outputter; -}; - +typedef CPPUNIT_NS::TextUi::TestRunner TextTestRunner; -} // namespace TextUi CPPUNIT_NS_END diff --git a/include/cppunit/ui/text/TextTestRunner.h b/include/cppunit/ui/text/TextTestRunner.h new file mode 100644 index 0000000..dee37a7 --- /dev/null +++ b/include/cppunit/ui/text/TextTestRunner.h @@ -0,0 +1,94 @@ +#ifndef CPPUNIT_TEXTTESTRUNNER_H +#define CPPUNIT_TEXTTESTRUNNER_H + + +#include <cppunit/Portability.h> +#include <string> +#include <vector> +#include <cppunit/TestRunner.h> + +CPPUNIT_NS_BEGIN + + +class Outputter; +class Test; +class TestSuite; +class TextOutputter; +class TestResult; +class TestResultCollector; + + + +/*! + * \brief A text mode test runner. + * \ingroup WritingTestResult + * \ingroup ExecutingTest + * + * The test runner manage the life cycle of the added tests. + * + * The test runner can run only one of the added tests or all the tests. + * + * TestRunner prints out a trace as the tests are executed followed by a + * summary at the end. The trace and summary print are optional. + * + * Here is an example of use: + * + * \code + * CppUnit::TextTestRunner runner; + * runner.addTest( ExampleTestCase::suite() ); + * runner.run( "", true ); // Run all tests and wait + * \endcode + * + * The trace is printed using a TextTestProgressListener. The summary is printed + * using a TextOutputter. + * + * You can specify an alternate Outputter at construction + * or later with setOutputter(). + * + * After construction, you can register additional TestListener to eventManager(), + * for a custom progress trace, for example. + * + * \code + * CppUnit::TextTestRunner runner; + * runner.addTest( ExampleTestCase::suite() ); + * runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( + * &runner.result(), + * std::cerr ) ); + * MyCustomProgressTestListener progress; + * runner.eventManager().addListener( &progress ); + * runner.run( "", true ); // Run all tests and wait + * \endcode + * + * \see CompilerOutputter, XmlOutputter, TextOutputter. + */ +class CPPUNIT_API TextTestRunner : public CPPUNIT_NS::TestRunner +{ +public: + TextTestRunner( Outputter *outputter =NULL ); + + virtual ~TextTestRunner(); + + bool run( std::string testPath ="", + bool doWait = false, + bool doPrintResult = true, + bool doPrintProgress = true ); + + void setOutputter( Outputter *outputter ); + + TestResultCollector &result() const; + + TestResult &eventManager() const; + +protected: + virtual void wait( bool doWait ); + virtual void printResult( bool doPrintResult ); + + TestResultCollector *m_result; + TestResult *m_eventManager; + Outputter *m_outputter; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TEXTTESTRUNNER_H |
