1 #ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
2 #define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
4 #include <cppunit/Portability.h>
5 #include <cppunit/portability/CppUnitMap.h>
8 #if CPPUNIT_NEED_DLL_DECL
9 #pragma warning( push )
10 #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
18 class TestFixtureFactory;
21 /*! \brief Context used when creating test suite in HelperMacros.
23 * Base class for all context used when creating test suite. The
24 * actual context type during test suite creation is TestSuiteBuilderContext.
26 * \sa CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_ADD_TEST,
27 * CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS.
29 class CPPUNIT_API TestSuiteBuilderContextBase
32 /*! \brief Constructs a new context.
34 * You should not use this. The context is created in
35 * CPPUNIT_TEST_SUITE().
37 TestSuiteBuilderContextBase( TestSuite &suite,
38 const TestNamer &namer,
39 TestFixtureFactory &factory );
41 virtual ~TestSuiteBuilderContextBase();
43 /*! \brief Adds a test to the fixture suite.
45 * \param test Test to add to the fixture suite. Must not be \c NULL.
47 void addTest( Test *test );
49 /*! \brief Returns the fixture name.
50 * \return Fixture name. It is the name used to name the fixture
53 std::string getFixtureName() const;
55 /*! \brief Returns the name of the test for the specified method.
57 * \param testMethodName Name of the method that implements a test.
58 * \return A string that is the concatenation of the test fixture name
59 * (returned by getFixtureName()) and\a testMethodName,
60 * separated using '::'. This provides a fairly unique name for a given
63 std::string getTestNameFor( const std::string &testMethodName ) const;
65 /*! \brief Adds property pair.
66 * \param key PropertyKey string to add.
67 * \param value PropertyValue string to add.
69 void addProperty( const std::string &key,
70 const std::string &value );
72 /*! \brief Returns property value assigned to param key.
73 * \param key PropertyKey string.
75 const std::string getStringProperty( const std::string &key ) const;
78 TestFixture *makeTestFixture() const;
80 // Notes: we use a vector here instead of a map to work-around the
81 // shared std::map in dll bug in VC6.
82 // See http://www.dinkumware.com/vc_fixes.html for detail.
83 typedef std::pair<std::string,std::string> Property;
84 typedef CppUnitVector<Property> Properties;
87 const TestNamer &m_namer;
88 TestFixtureFactory &m_factory;
91 Properties m_properties;
95 /*! \brief Type-sage context used when creating test suite in HelperMacros.
97 * \sa TestSuiteBuilderContextBase.
99 template<class Fixture>
100 class TestSuiteBuilderContext : public TestSuiteBuilderContextBase
103 typedef Fixture FixtureType;
105 TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase )
106 : TestSuiteBuilderContextBase( contextBase )
110 /*! \brief Returns a new TestFixture instance.
111 * \return A new fixture instance. The fixture instance is returned by
112 * the TestFixtureFactory passed on construction. The actual type
113 * is that of the fixture on which the static method suite()
116 FixtureType *makeFixture() const
118 return CPPUNIT_STATIC_CAST( FixtureType *,
119 TestSuiteBuilderContextBase::makeTestFixture() );
126 #if CPPUNIT_NEED_DLL_DECL
127 #pragma warning( pop )
130 #endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H