我有两个名为“ TT_Common ”和“ TT_Container ”的测试类,它们扩展了 CPPUNIT_NS::TestFixture:
class TT_Common : public CPPUNIT_NS::TestFixture ......
class TT_Container : public CPPUNIT_NS::TestFixture ......
另一个名为 TT_Runner 的类扩展了 CPPUNIT_NS::TestRunner:
class TT_Runner : public CPPUNIT_NS::TestRunner
{
.....
void run( CPPUNIT_NS::TestResult &controller, const std::string &testPath )
{
CPPUNIT_NS::TestPath path = m_suite->resolveTestPath( testPath );
CPPUNIT_NS::Test *testToRun = path.getChildTest();
for ( size_t iIdx = 0; iIdx < testToRun->getChildTestCount(); iIdx++ )
{
CPPUNIT_NS::Test* psTest = testToRun->getChildTestAt(iIdx);
std::string testName = psTest->getName();
// testName is TT_Common for iIdx = 0 and TT_Container for iIdx = 1
}
}
我已经有了TestFixture 的名称,但是如何创建它的实例?我找不到采用名称并返回实例的工厂或注册表。