test.h
Go to the documentation of this file.00001 #ifndef CPPUT_TEST_H_INCLUDED
00002 # define CPPUT_TEST_H_INCLUDED
00003
00004 # include <cpput/forwards.h>
00005 # include <json/value.h>
00006 # include <cpptl/conststring.h>
00007 # include <cpptl/intrusiveptr.h>
00008 # include <string>
00009
00010
00011 namespace CppUT {
00012
00013 class TestVisitor;
00014
00020 class CPPUT_API Test : public CppTL::IntrusiveCount
00021 {
00022
00023
00024 friend class AbstractTestCase;
00025 friend class AbstractTestSuite;
00026 public:
00027 virtual ~Test()
00028 {
00029 }
00030
00031 void setDescription( const std::string &description )
00032 {
00033 info_["configuration/description"] = description;
00034 }
00035
00036 std::string description() const
00037 {
00038 return info_.get("configuration/description", "" ).asString();
00039 }
00040
00041 std::string name() const
00042 {
00043 return info_.get( "configuration/name", "" ).asString();
00044 }
00045
00046 void setTimeOut( double timeOutInSeconds )
00047 {
00048 info_["configuration/timeOut"] = timeOutInSeconds;
00049 }
00050
00051 double timeOut() const
00052 {
00053 return info_.get( "configuration/timeOut", 0.0 ).asDouble();
00054 }
00055
00056 void addToGroup( const std::string &groupName )
00057 {
00058 info_["configuration"]["groups"].append( groupName );
00059 }
00060
00061 int groupCount() const
00062 {
00063 return info_["configuration"]["groups"].size();
00064 }
00065
00066 std::string groupAt( unsigned int index ) const
00067 {
00068 return info_["configuration"]["groups"][index].asString();
00069 }
00070
00073 void setName( const std::string &name )
00074 {
00075 info_["configuration/name"] = name;
00076 }
00077
00078
00079
00080
00081
00082
00085
00086
00087
00088
00089
00091 bool isTestSuite() const
00092 {
00093 return !isTestCase();
00094 }
00095
00096 virtual void accept( TestVisitor &visitor ) = 0;
00097
00099 virtual bool isTestCase() const = 0;
00100
00101 private:
00102 Test()
00103 {
00104 setName( "<undefined>" );
00105 }
00106
00107 Test( const std::string &name )
00108 {
00109 setName( name );
00110 }
00111
00112 private:
00113 Json::Value info_;
00114 };
00115
00116
00117 }
00118
00119 #endif // CPPUT_TEST_H_INCLUDED