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_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 }
00160
00161 }
00162
00163 #endif