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 library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  * 
00009  * As a special exception, you may use this file as part of a free
00010  * software library without restriction. Specifically, if other files
00011  * instantiate templates or use macros or inline functions from this
00012  * file, or you compile this file and link it with other files to
00013  * produce an executable, this file does not by itself cause the
00014  * resulting executable to be covered by the GNU General Public
00015  * License. This exception does not however invalidate any other
00016  * reasons why the executable file might be covered by the GNU Library
00017  * General Public License.
00018  * 
00019  * This library is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * Lesser General Public License for more details.
00023  * 
00024  * You should have received a copy of the GNU Lesser General Public
00025  * License along with this library; if not, write to the Free Software
00026  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00027  */
00028 #ifndef CXXTOOLS_UNIT_REPORTER_H
00029 #define CXXTOOLS_UNIT_REPORTER_H
00030 
00031 #include <cxxtools/unit/assertion.h>
00032 #include <cxxtools/unit/testcontext.h>
00033 #include <cxxtools/signal.h>
00034 #include <cxxtools/noncopyable.h>
00035 #include <iosfwd>
00036 #include <stdexcept>
00037 
00038 namespace cxxtools {
00039 
00040 namespace unit {
00041 
00049 class Reporter : protected NonCopyable
00050 {
00051     public:
00054         virtual ~Reporter()
00055         { destroyed.send(*this);}
00056 
00064         virtual void reportStart(const TestContext& test) = 0;
00065 
00073         virtual void reportFinish(const TestContext& test) = 0;
00074 
00082         virtual void reportMessage(const std::string& msg) = 0;
00083 
00090         virtual void reportSuccess(const TestContext& test) = 0;
00091 
00099         virtual void reportAssertion(const TestContext& test, const Assertion& a) = 0;
00100 
00109         virtual void reportException(const TestContext& test, const std::exception& ex) = 0;
00110 
00118         virtual void reportError(const TestContext& test) = 0;
00119 
00120         Signal<Reporter&> destroyed;
00121 
00122     protected:
00125         Reporter()
00126         {}
00127 };
00128 
00129 
00130 class BriefReporter : public Reporter
00131 {
00132     public:
00133         explicit BriefReporter(std::ostream* out = &std::cout);
00134 
00135         virtual ~BriefReporter();
00136 
00137         void setOutput(std::ostream& out);
00138 
00139         virtual void reportStart(const TestContext& test);
00140 
00141         virtual void reportFinish(const TestContext& test);
00142 
00143         virtual void reportMessage(const std::string& msg);
00144 
00145         virtual void reportSuccess(const TestContext& test);
00146 
00147         virtual void reportAssertion(const TestContext& test, const Assertion& a);
00148 
00149         virtual void reportException(const TestContext& test, const std::exception& ex);
00150 
00151         virtual void reportError(const TestContext& test);
00152 
00153     private:
00156         std::ostream* _out;
00157 };
00158 
00159 } // namespace unit
00160 
00161 } // namespace cxxtools
00162 
00163 #endif
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6