Menu

Macros to create test suites...

2001-04-15
2001-05-20
  • Baptiste Lepilleur

      Hi, I developped a set of macros to make it easier to create test suite.

      Here is the adapted example:

    template<class GAMECLASS>
    class ChessTest : public BoardGameTest<GAMECLASS> {
        CU_TEST_SUB_SUITE( ChessTest<GAMECLASS>, BoardGameTest<GAMECLASS> );
        CU_TEST( testNumberOfPieces );
        CU_TEST_SUITE_END();
      public:
    ...
    }

    in main.cpp (or any other cpp), to automatically register the test suite created for the class in the registry:

    CU_TEST_SUITE_REGISTRATION( ChessTest<Chess> );

    This make it a lot easier to create test. I'd would like to know how I can contribute this features to the project (I'm using WinCVS and VC++ 6.0).

    The modified version is available at http://gaiacrtn.free.fr/cppunit/CppUnit-autoreg-20010415-21h27.zip (200Ko)

    It is based on version 1.5.4 (downloaded this morning), and have been modified to compile with VC++ 6.0, but there should be no trouble on unix. Look at the example and the file cppunit/AutoRegisterTests.h for documentation.

    The main change are:
    TestCase.cpp: test are not automatically registered (major source of bug, when a test is on the stack, the registry will try to delete it).

    TestRegistry.cpp: modified it so that we know when the static is initialized (probably the source of the reported bug on solaris).

    AutoRegisterTests.h: macros and template class needed test automatic registration.

     
    • Dakshinamurthy Karra

      Atlast. I am planning to do this for sometime, but could not manage. I am sure with a little bit of pre-processor trickery cppunit usage can be made little easier.

       
    • Baptiste Lepilleur

      I keep seeing people downloading this file.

      You should know that CppUnitW 1.2 features (macros and TestSuiteBuidler) have been included in release 1.5.5.

      CppUnit release 1.5.5 is more mature than this version. So you know what you have to do now ;-)

      Thanks for your support,
      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.