CppUnit project page | FAQ | CppUnit home page

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

TestSuiteBuilderContext.h
Go to the documentation of this file.
1 #ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
2 #define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
3
4 #include <cppunit/Portability.h>
5 #include <cppunit/portability/CppUnitMap.h>
6 #include <string>
7
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
11 #endif
12
13
14 CPPUNIT_NS_BEGIN
15
16 class TestSuite;
17 class TestFixture;
18 class TestFixtureFactory;
19 class TestNamer;
20
29 class CPPUNIT_API TestSuiteBuilderContextBase
30 {
31 public:
37 TestSuiteBuilderContextBase( TestSuite &suite,
38 const TestNamer &namer,
39 TestFixtureFactory &factory );
40
41 virtual ~TestSuiteBuilderContextBase();
42
47 void addTest( Test *test );
48
53 std::string getFixtureName() const;
54
63 std::string getTestNameFor( const std::string &testMethodName ) const;
64
69 void addProperty( const std::string &key,
70 const std::string &value );
71
75 const std::string getStringProperty( const std::string &key ) const;
76
77 protected:
78 TestFixture *makeTestFixture() const;
79
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;
85
86 TestSuite &m_suite;
87 const TestNamer &m_namer;
88 TestFixtureFactory &m_factory;
89
90 private:
91 Properties m_properties;
92 };
93
94
99 template<class Fixture>
100 class TestSuiteBuilderContext : public TestSuiteBuilderContextBase
101 {
102 public:
103 typedef Fixture FixtureType;
104
105 TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase )
106 : TestSuiteBuilderContextBase( contextBase )
107 {
108 }
109
116 FixtureType *makeFixture() const
117 {
118 return CPPUNIT_STATIC_CAST( FixtureType *,
119 TestSuiteBuilderContextBase::makeTestFixture() );
120 }
121 };
122
123
124 CPPUNIT_NS_END
125
126 #if CPPUNIT_NEED_DLL_DECL
127 #pragma warning( pop )
128 #endif
129
130 #endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
131
TestSuiteBuilderContext::TestSuiteBuilderContext
TestSuiteBuilderContext(TestSuiteBuilderContextBase &contextBase)
Definition: TestSuiteBuilderContext.h:105
TestFixture
Wraps a test case with setUp and tearDown methods.A TestFixture is used to provide a common environme...
Definition: TestFixture.h:83
TestSuiteBuilderContextBase::m_factory
TestFixtureFactory & m_factory
Definition: TestSuiteBuilderContext.h:88
Portability.h
TestSuiteBuilderContext
Type-sage context used when creating test suite in HelperMacros.
Definition: TestSuiteBuilderContext.h:100
CppUnitMap.h
TestSuiteBuilderContextBase::m_suite
TestSuite & m_suite
Definition: TestSuiteBuilderContext.h:86
TestSuiteBuilderContext::makeFixture
FixtureType * makeFixture() const
Returns a new TestFixture instance.
Definition: TestSuiteBuilderContext.h:116
TestFixtureFactory
Abstract TestFixture factory (Implementation).
Definition: TestFixtureFactory.h:16
Test
Base class for all test objects.All test objects should be a subclass of Test. Some test objects...
Definition: Test.h:25
CPPUNIT_STATIC_CAST
#define CPPUNIT_STATIC_CAST(TargetType, pointer)
Definition: Portability.h:101
TestSuiteBuilderContextBase::Property
std::pair< std::string, std::string > Property
Definition: TestSuiteBuilderContext.h:83
TestSuiteBuilderContextBase::m_namer
const TestNamer & m_namer
Definition: TestSuiteBuilderContext.h:87
TestSuiteBuilderContextBase
Context used when creating test suite in HelperMacros.
Definition: TestSuiteBuilderContext.h:29
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:120
TestSuiteBuilderContext::FixtureType
Fixture FixtureType
Definition: TestSuiteBuilderContext.h:103
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:119
TestSuiteBuilderContextBase::makeTestFixture
TestFixture * makeTestFixture() const
Definition: TestSuiteBuilderContext.cpp:48
TestNamer
Names a test or a fixture suite.
Definition: TestNamer.h:50
TestSuiteBuilderContextBase::m_properties
Properties m_properties
Definition: TestSuiteBuilderContext.h:91
TestSuite
A Composite of Tests.It runs a collection of test cases. Here is an example.
Definition: TestSuite.h:40
TestSuiteBuilderContextBase::Properties
CppUnitVector< Property > Properties
Definition: TestSuiteBuilderContext.h:84
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27

| hosts this site. |  | Send comments to: CppUnit Developers