00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 }
00152
00153 }
00154
00155 #endif