00001 #ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
00002 #define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
00003
00004 #include <cppunit/Portability.h>
00005 #include <cppunit/portability/CppUnitMap.h>
00006 #include <string>
00007
00008 #if CPPUNIT_NEED_DLL_DECL
00009 #pragma warning( push )
00010 #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
00011 #endif
00012
00013 CPPUNIT_NS_BEGIN
00014
00015 class TestSuite;
00016 class TestFixture;
00017 class TestFixtureFactory;
00018 class TestNamer;
00019
00028 class CPPUNIT_API TestSuiteBuilderContextBase
00029 {
00030 public:
00036 TestSuiteBuilderContextBase( TestSuite &suite,
00037 const TestNamer &namer,
00038 TestFixtureFactory &factory );
00039
00044 void addTest( Test *test );
00045
00050 std::string getFixtureName() const;
00051
00060 std::string getTestNameFor( const std::string &testMethodName ) const;
00061
00066 void addProperty( const std::string &key,
00067 const std::string &value );
00068
00072 const std::string getStringProperty( const std::string &key ) const;
00073
00074 protected:
00075 TestFixture *makeTestFixture() const;
00076
00077 typedef CppUnitMap<std::string,std::string> Properties;
00078
00079 TestSuite &m_suite;
00080 const TestNamer &m_namer;
00081 TestFixtureFactory &m_factory;
00082 Properties m_properties;
00083 };
00084
00085
00090 template<class Fixture>
00091 class TestSuiteBuilderContext : public TestSuiteBuilderContextBase
00092 {
00093 public:
00094 typedef Fixture FixtureType;
00095
00096 TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase )
00097 : TestSuiteBuilderContextBase( contextBase )
00098 {
00099 }
00100
00107 FixtureType *makeFixture() const
00108 {
00109 return CPPUNIT_STATIC_CAST( FixtureType *,
00110 TestSuiteBuilderContextBase::makeTestFixture() );
00111 }
00112 };
00113
00114
00115 CPPUNIT_NS_END
00116
00117 #if CPPUNIT_NEED_DLL_DECL
00118 #pragma warning( pop )
00119 #endif
00120
00121 #endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
00122