00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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 }
00150
00151 }
00152
00153 #endif