summaryrefslogtreecommitdiff
path: root/include/cppunit/ui
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-10 14:22:30 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-10 14:22:30 +0000
commit6c2d743aed2eb4c0a960edaadc7366faa3b24c5c (patch)
treeb41f82e9b41c48e9dcb1cc59833dff26e88817d7 /include/cppunit/ui
parent0e44bc8d5fa467b9d1c835b2e40b17f538e4bbe3 (diff)
downloadcppunit-6c2d743aed2eb4c0a960edaadc7366faa3b24c5c.tar.gz
Include/cppunitui/: moved to include/cppunit/ui (fix unix install problem).
include/cppunitui/: moved to include/cppunit/ui (fix unix install problem). * doc/cookbook.dox: * examples/cppunittest/CppUnitTestMain.cpp: * examples/msvc/CppUnitTestApp/HostApp.cpp: * examples/msvc/HostApp/HostApp.cpp: * examples/qt/Main.Cpp: * examples/src/cppunit/TestRunner.cpp: * examples/src/msvc6/TestRunner/TestRunner.cpp: * examples/src/qttestrunner/TestRunner.cpp: updated to use <cppunit/ui/...> instead of <cppunitui/...> in include directives. * doc/CppUnit-win.dox: generated documentation give the include path at the bottom of the page for each class. * NEWS: added compatibility break for 1.7.10 users.
Diffstat (limited to 'include/cppunit/ui')
-rw-r--r--include/cppunit/ui/mfc/TestRunner.h83
-rw-r--r--include/cppunit/ui/qt/Config.h21
-rw-r--r--include/cppunit/ui/qt/TestRunner.h81
-rw-r--r--include/cppunit/ui/text/TestRunner.h103
4 files changed, 288 insertions, 0 deletions
diff --git a/include/cppunit/ui/mfc/TestRunner.h b/include/cppunit/ui/mfc/TestRunner.h
new file mode 100644
index 0000000..b58ee42
--- /dev/null
+++ b/include/cppunit/ui/mfc/TestRunner.h
@@ -0,0 +1,83 @@
+#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
+ */
+
+namespace CppUnit
+{
+ class Test;
+ class TestSuite;
+
+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( CppUnit::Test *test );
+
+ void addTests( const std::vector<CppUnit::Test *> &tests );
+
+protected:
+ CppUnit::Test *getRootTest();
+
+ CppUnit::TestSuite *m_suite;
+
+ typedef std::vector<CppUnit::Test *> Tests;
+ Tests m_tests;
+};
+
+
+} // namespace MfcUi
+
+} // namespace CppUnit
+
+
+#endif // CPPUNITUI_MFC_TESTRUNNER_H
diff --git a/include/cppunit/ui/qt/Config.h b/include/cppunit/ui/qt/Config.h
new file mode 100644
index 0000000..73eac3c
--- /dev/null
+++ b/include/cppunit/ui/qt/Config.h
@@ -0,0 +1,21 @@
+#ifndef CPPUNIT_QTUI_CONFIG_H
+#define CPPUNIT_QTUI_CONFIG_H
+
+/*! Macro to export symbol to DLL with VC++.
+ *
+ * - QTTESTRUNNER_DLL_BUILD must be defined when building the DLL.
+ * - QTTESTRUNNER_DLL must be defined if linking against the DLL.
+ * - If none of the above are defined then you are building or linking against
+ * the static library.
+ */
+
+#if defined( QTTESTRUNNER_DLL_BUILD )
+# define QTTESTRUNNER_API __declspec(dllexport)
+#elif defined ( QTTESTRUNNER_DLL )
+# define QTTESTRUNNER_API __declspec(dllimport)
+#else
+# define QTTESTRUNNER_API
+#endif
+
+
+#endif // CPPUNIT_QTUI_CONFIG_H \ No newline at end of file
diff --git a/include/cppunit/ui/qt/TestRunner.h b/include/cppunit/ui/qt/TestRunner.h
new file mode 100644
index 0000000..d293b08
--- /dev/null
+++ b/include/cppunit/ui/qt/TestRunner.h
@@ -0,0 +1,81 @@
+// //////////////////////////////////////////////////////////////////////////
+// Header file TestRunner.h for class TestRunner
+// (c)Copyright 2000, Baptiste Lepilleur.
+// Created: 2001/09/19
+// //////////////////////////////////////////////////////////////////////////
+#ifndef CPPUNIT_QTUI_TESTRUNNER_H
+#define CPPUNIT_QTUI_TESTRUNNER_H
+
+#include <vector>
+#include "Config.h"
+
+namespace CppUnit
+{
+ 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( CppUnit::Test *test );
+
+private:
+ /// Prevents the use of the copy constructor.
+ TestRunner( const TestRunner &copy );
+
+ /// Prevents the use of the copy operator.
+ void operator =( const TestRunner &copy );
+
+ Test *getRootTest();
+
+private:
+ typedef std::vector<Test *> Tests;
+ Tests *_tests;
+
+ TestSuite *_suite;
+};
+
+
+
+// Inlines methods for TestRunner:
+// -------------------------------
+
+
+ } // namespace QtUi
+} // namespace CppUnit
+
+#endif // CPPUNIT_QTUI_TESTRUNNER_H
diff --git a/include/cppunit/ui/text/TestRunner.h b/include/cppunit/ui/text/TestRunner.h
new file mode 100644
index 0000000..6bfa6c9
--- /dev/null
+++ b/include/cppunit/ui/text/TestRunner.h
@@ -0,0 +1,103 @@
+#ifndef CPPUNITUI_TEXT_TESTRUNNER_H
+#define CPPUNITUI_TEXT_TESTRUNNER_H
+
+#include <cppunit/Portability.h>
+#include <string>
+#include <vector>
+
+namespace CppUnit {
+
+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.
+ */
+class CPPUNIT_API TestRunner
+{
+public:
+ TestRunner( Outputter *outputter =NULL );
+
+ virtual ~TestRunner();
+
+ bool run( std::string testName ="",
+ bool doWait = false,
+ bool doPrintResult = true,
+ bool doPrintProgress = true );
+
+ void addTest( Test *test );
+
+ void setOutputter( Outputter *outputter );
+
+ TestResultCollector &result() const;
+
+ TestResult &eventManager() const;
+
+protected:
+ virtual bool runTest( Test *test,
+ bool doPrintProgress );
+ virtual bool runTestByName( std::string testName,
+ bool printProgress );
+ virtual void wait( bool doWait );
+ virtual void printResult( bool doPrintResult );
+
+ virtual Test *findTestByName( std::string name ) const;
+
+ TestSuite *m_suite;
+ TestResultCollector *m_result;
+ TestResult *m_eventManager;
+ Outputter *m_outputter;
+};
+
+
+} // namespace TextUi
+
+} // namespace CppUnit
+
+#endif // CPPUNITUI_TEXT_TESTRUNNER_H