I have been having trouble with the CPPUNIT_TEST_SUITE_REGISTRATION macro in a library. VC++ does not seem to recognize the fact that the test class is being stored in a static variable elsewhere. The net result of this is that the file does not get linked in, so the CPPUNIT_TEST_SUITE_REGISTRATION macro never get's executed and the test never gets added.
Has anyone else had this problem, or does anyone else know of a way to fix this aside from forcing a link by acessing a member of the CPP file from the executable?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Look at my 2 posts in the thread on "possible bugs in Registry extension files?".
I got the CPPUNIT_TEST_SUITE_REGISTRATION macro working by putting the CPPUNIT_TEST_SUITE_REGISTRATION macro for every test suite in the same file as a function that gets linked. This kept the MSVC linker happy. When I put each CPPUNIT_TEST_SUITE_REGISTRATION macro in the various cpp files where each test suite was defined, as any sane programmer would, my test suites were not added.
Hope this helps!
Mark Delaney
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My first foray into CppUnit was this past week- I had objects split into three files, say "object.h", "object.cpp", and "object_t.cpp". I put TEST_SUITE_REGISTRATION and all of the test code AND the CppUnit::TestCase-derived class definition in the _t.cpp file. Compiled and linked fine. I could take all of the _t.cpp files out of the project and everything still worked as it should have. I thought that was beauty.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been having trouble with the CPPUNIT_TEST_SUITE_REGISTRATION macro in a library. VC++ does not seem to recognize the fact that the test class is being stored in a static variable elsewhere. The net result of this is that the file does not get linked in, so the CPPUNIT_TEST_SUITE_REGISTRATION macro never get's executed and the test never gets added.
Has anyone else had this problem, or does anyone else know of a way to fix this aside from forcing a link by acessing a member of the CPP file from the executable?
Look at my 2 posts in the thread on "possible bugs in Registry extension files?".
I got the CPPUNIT_TEST_SUITE_REGISTRATION macro working by putting the CPPUNIT_TEST_SUITE_REGISTRATION macro for every test suite in the same file as a function that gets linked. This kept the MSVC linker happy. When I put each CPPUNIT_TEST_SUITE_REGISTRATION macro in the various cpp files where each test suite was defined, as any sane programmer would, my test suites were not added.
Hope this helps!
Mark Delaney
hmm-
My first foray into CppUnit was this past week- I had objects split into three files, say "object.h", "object.cpp", and "object_t.cpp". I put TEST_SUITE_REGISTRATION and all of the test code AND the CppUnit::TestCase-derived class definition in the _t.cpp file. Compiled and linked fine. I could take all of the _t.cpp files out of the project and everything still worked as it should have. I thought that was beauty.