Menu

How to create hierarchy?

Help
Anonymous
2002-07-17
2002-07-18
  • Anonymous

    Anonymous - 2002-07-17

    I need to create deep tests hierarchy.

    Is it possible to add one named registry into another one?

    Thanks in advance.

     
    • Wolfgang Stoecher

      I added a new macro to HelperMacros.h:

      #define CPPUNIT_INSERT_SUITE( testSuite )  \
         CppUnit::TestSuiteFactory<testSuite>* __CPPUNIT_CONCATENATE( suite, testSuite ) = \
            new CppUnit::TestSuiteFactory<testSuite>(); \
         builder.addTest(__CPPUNIT_CONCATENATE( suite, testSuite )->makeTest()); \
         delete __CPPUNIT_CONCATENATE( suite, testSuite ); \
         factory = factory; // suppress unused warning

      A top node in the hierarchy (below "All Tests") is again a TestFixture, which maybe almost empty except for "inserting" the next levels:
      class AutoTest : public CppUnit::TestFixture
      {
         CPPUNIT_TEST_SUITE( AutoTest );
         CPPUNIT_INSERT_SUITE(BuchseTest);
        ...
         CPPUNIT_TEST_SUITE_END();
      ...
      }

      The inserted suite does not need the automatic registration in the cpp-file.

      hope that helps,

      Wolfgang

       
    • Baptiste Lepilleur

      Yes.

      Refer to cppunit 1.9.8 documentation, module/Creating TestSuite.

      Look up:
      CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
      CPPUNIT_REGISTRY_ADD
      CPPUNIT_REGISTRY_ADD_TO_DEFAULT

      Baptiste.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.