Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

/home/tommi/cxxtools/include/cxxtools/unit/reporter.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2006 by Dr. Marc Boris Duerner                     *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU Library General Public License as       *
00006  *   published by the Free Software Foundation; either version 2 of the    *
00007  *   License, or (at your option) any later version.                       *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Library General Public     *
00015  *   License along with this program; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00018  ***************************************************************************/
00019 #ifndef CXXTOOLS_UNIT_REPORTER_H
00020 #define CXXTOOLS_UNIT_REPORTER_H
00021 
00022 #include <cxxtools/unit/api.h>
00023 #include <cxxtools/unit/assertion.h>
00024 #include <cxxtools/unit/testcontext.h>
00025 #include <cxxtools/signals.h>
00026 #include <cxxtools/noncopyable.h>
00027 #include <iosfwd>
00028 #include <stdexcept>
00029 
00030 namespace cxxtools {
00031 
00032 namespace unit {
00033 
00041 class CXXTOOLS_UNIT_API Reporter : protected NonCopyable
00042 {
00043     public:
00046         virtual ~Reporter()
00047         { destroyed.send(*this);}
00048 
00056         virtual void reportStart(const TestContext& test) = 0;
00057 
00065         virtual void reportFinish(const TestContext& test) = 0;
00066 
00074         virtual void reportMessage(const std::string& msg) = 0;
00075 
00082         virtual void reportSuccess(const TestContext& test) = 0;
00083 
00091         virtual void reportAssertion(const TestContext& test, const Assertion& a) = 0;
00092 
00101         virtual void reportException(const TestContext& test, const std::exception& ex) = 0;
00102 
00110         virtual void reportError(const TestContext& test) = 0;
00111 
00112         Signal<Reporter&> destroyed;
00113 
00114     protected:
00117         Reporter()
00118         {}
00119 };
00120 
00121 
00122 class CXXTOOLS_UNIT_API BriefReporter : public Reporter
00123 {
00124     public:
00125         explicit BriefReporter(std::ostream* out = &std::cout);
00126 
00127         virtual ~BriefReporter();
00128 
00129         void setOutput(std::ostream& out);
00130 
00131         virtual void reportStart(const TestContext& test);
00132 
00133         virtual void reportFinish(const TestContext& test);
00134 
00135         virtual void reportMessage(const std::string& msg);
00136 
00137         virtual void reportSuccess(const TestContext& test);
00138 
00139         virtual void reportAssertion(const TestContext& test, const Assertion& a);
00140 
00141         virtual void reportException(const TestContext& test, const std::exception& ex);
00142 
00143         virtual void reportError(const TestContext& test);
00144 
00145     private:
00148         std::ostream* _out;
00149 };
00150 
00151 } // namespace unit
00152 
00153 } // namespace cxxtools
00154 
00155 #endif
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6