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

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

00001 /*
00002  * Copyright (C) 2005-2008 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_TEST_H
00029 #define CXXTOOLS_UNIT_TEST_H
00030 
00031 #include <cxxtools/unit/reporter.h>
00032 #include <cxxtools/unit/assertion.h>
00033 #include <cxxtools/connectable.h>
00034 #include <cxxtools/noncopyable.h>
00035 #include <string>
00036 
00037 namespace cxxtools {
00038 
00039 namespace unit {
00040 
00041     class TestContext;
00042 
00051     class Test : public Connectable,
00052                  protected NonCopyable
00053     {
00054         public:
00057             virtual ~Test()
00058             { }
00059 
00073             virtual void run() = 0;
00074 
00075             const std::string& name() const;
00076 
00079             void reportStart(const TestContext& ctx);
00080 
00086             void reportFinish(const TestContext& ctx);
00087 
00092             void reportSuccess(const TestContext& ctx);
00093 
00098             void reportAssertion(const TestContext& ctx, const Assertion& ass);
00099 
00104             void reportException(const TestContext& ctx, const std::exception& ex);
00105 
00110             void reportError(const TestContext& ctx);
00111 
00116             void reportMessage(const std::string& msg);
00117 
00118             void setParent(Test* test);
00119 
00120             Test* parent();
00121 
00122             const Test* parent() const;
00123 
00130             void attachReporter(Reporter& r);
00131 
00132             void detachReporter(Reporter& r);
00133 
00134         protected:
00138             explicit Test(const std::string& name)
00139             : _name(name)
00140             , _parent(0)
00141             { }
00142 
00143         private:
00144             std::string _name;
00145             Test* _parent;
00146             std::list<Reporter*> _reporter;
00147     };
00148 
00149 } // namespace unit
00150 
00151 } // namespace cxxtools
00152 
00153 #endif
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6