[Cppunit-devel] Question on 1.9.14
Brought to you by:
blep
From: Paul_Tletski@Progressive.com - 2004-05-19 12:49:46
|
I had an app that loaded two DLL's then executed the test runner on those DLLs. It works for 1.8. In 1.9.14 I am getting an exception. I've boldened the appropriate flow. I checked and made sure that I am using 1.9.14 headers, libs, DLLs, etc. void CAppProjectApp::RunUnitTests() { // TestDLL_1 and TestDLL_2 are MFC extension DLLs. if (AfxLoadLibrary("TestDLL_1.dll") && AfxLoadLibrary("TestDLL_2.dll")) { CppUnit::MfcUi::TestRunner runner; // Tell the Test Runner to do its thing. CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); CppUnit::Test *pSuite = registry.makeTest(); // This is causing an exception. if (pSuite != 0) { runner.addTest(pSuite); runner.run(); } } else { // Bad load. ASSERT(FALSE); } } Test * TestFactoryRegistry::makeTest() { TestSuite *suite = new TestSuite( m_name ); addTestToSuite( suite ); return suite; } void TestFactoryRegistry::addTestToSuite( TestSuite *suite ) { for ( Factories::iterator it = m_factories.begin(); it != m_factories.end(); ++it ) { TestFactory *factory = *it; suite->addTest( factory->makeTest() ); } } template<class TestCaseType> class TestSuiteFactory : public TestFactory { public: virtual Test *makeTest() { return TestCaseType::suite(); } }; The defs for the tests: class _impexp_testdll1_ CTestClass_1 : public CppUnit::TestCase { CPPUNIT_TEST_SUITE(CTestClass_1); // this crashes CPPUNIT_TEST(TestOperation1); CPPUNIT_TEST(TestOperation2); CPPUNIT_TEST(TestOperation3); CPPUNIT_TEST_SUITE_END(); // Factory public: CTestClass_1(); virtual ~CTestClass_1(); // Test Operations public: void setUp(); protected: void TestOperation1(); void TestOperation2(); void TestOperation3(); }; In the cpp: CPPUNIT_TEST_SUITE_REGISTRATION(CTestClass_1); class _impexp_testdll2_ CTestClass_2 : public CppUnit::TestCase { CPPUNIT_TEST_SUITE(CTestClass_2); CPPUNIT_TEST(TestOperation1); CPPUNIT_TEST(TestOperation2); CPPUNIT_TEST(TestOperation3); CPPUNIT_TEST_SUITE_END(); // Factory public: CTestClass_2(); virtual ~CTestClass_2(); // Test Operations public: void setUp(); protected: void TestOperation1(); void TestOperation2(); void TestOperation3(); }; In the cpp: CPPUNIT_TEST_SUITE_REGISTRATION(CTestClass_2); |