CppUnit - The Unit Testing Library

CppUnit project page | FAQ

TestNamer.h
Go to the documentation of this file.
1#ifndef CPPUNIT_EXTENSIONS_TESTNAMER_H
2#define CPPUNIT_EXTENSIONS_TESTNAMER_H
3
4#include <cppunit/Portability.h>
5#include <string>
6#include <cppunit/tools/StringHelper.h>
7
8#include <typeinfo>
9
10
11
28# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \
29 CPPUNIT_NS::TestNamer variableName( typeid(FixtureType) )
30
31 CPPUNIT_NS_BEGIN
32
38 class CPPUNIT_API TestNamer
39{
40public:
44 TestNamer( const std::type_info &typeInfo );
45
49 TestNamer( const std::string &fixtureName );
50
51 virtual ~TestNamer();
52
56 virtual std::string getFixtureName() const;
57
65 virtual std::string getTestNameFor( const std::string &testMethodName ) const;
66
67 template<typename E>
68 std::string getTestNameFor( const std::string& testMethodName, const E& val) const
69 {
70 return getTestNameFor(testMethodName) + " with parameter: " + CPPUNIT_NS::StringHelper::toString(val);
71 }
72
73protected:
74 std::string m_fixtureName;
75};
76
77 CPPUNIT_NS_END
78
79#endif // CPPUNIT_EXTENSIONS_TESTNAMER_H
80
CPPUNIT_API
#define CPPUNIT_API
Definition CppUnitApi.h:27
Portability.h
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition Portability.h:105
StringHelper.h
TestNamer::m_fixtureName
std::string m_fixtureName
Definition TestNamer.h:74
TestNamer::getFixtureName
virtual std::string getFixtureName() const
Returns the name of the fixture.
Definition TestNamer.cpp:23
TestNamer::getTestNameFor
std::string getTestNameFor(const std::string &testMethodName, const E &val) const
Definition TestNamer.h:68
TestNamer::getTestNameFor
virtual std::string getTestNameFor(const std::string &testMethodName) const
Returns the name of the test for the specified method.
Definition TestNamer.cpp:29
TestNamer::TestNamer
TestNamer(const std::type_info &typeInfo)
Constructs a namer using the fixture's type-info.
Definition TestNamer.cpp:8

| Send comments to: CppUnit Developers