Found my problem. I'd used the wrong macro to register the test with the test suite. All working happily.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-10-14
I'm having the same problem, i.e no tests are being found.
My project is compiled on a Suse 8.2 Linux using g++ and makefiles. Apparently something goes wrong when placing the object code that contains the suite registration (using the CPPUNIT_TEST_SUITE_NAMED_REGISTRATION macro)
in a seperate static library which is then linked with the main program object code. Because, when all sources are compiled & linked together in 1 step (not using a lib) everything works fine (i.e all tests are 'found').
Anyone any suggestions as to how this can occur?
All help will be greatly appreciated.
Greetings,
Kurt
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have to figure out how to disable dead code stripping in your tools. I'm guessing that what's happening (what usually happens) is that the linker is trying to be "smart" so it's removing objects that aren't referenced anywhere. Unfortunately this is exactly what you're looking for; the objects aren't referenced directly, but their constructors have side effects that make them get referenced.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-10-15
After examining the 2 binaries (the one that works & the one that doesn't work) with nm it is clear that object code for the test execution is not extracted from the library.
Using ld's -whole-archive option solves the problem.
Thanks for your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm doing a little feasibility, trying to get the CPPUnit mfc gui to point at a dll and run its tests.
In my dll, I have a test class:
<<the header>>
#include <cppunit/extensions/HelperMacros.h>
#include "MyTestDLL.h"
class MYTESTDLL_API TestTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( TestTest );
CPPUNIT_TEST( testStuff );
CPPUNIT_TEST_SUITE_END();
public:
TestTest();
virtual ~TestTest();
void testStuff();
};
<<end of header>>
<<the cpp>>
#include "stdafx.h"
#include "MyTestPluginInterface.h"
#include <cppunit/extensions/TestFactoryRegistry.h>
MyTestPluginInterface::MyTestPluginInterface()
{}
MyTestPluginInterface::~MyTestPluginInterface()
{}
CppUnit::Test *MyTestPluginInterface::makeTest()
{
CppUnit::Test *myTest = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
return myTest;
}
<<end of cpp>>
I have also subclassed the TestPlugInInterface:
<<header>>
#include "msvc6\testrunner\TestPlugInInterface.h"
#include "MyTestDLL.h"
class MYTESTDLL_API MyTestPluginInterface : public TestPlugInInterface
{
public:
MyTestPluginInterface();
virtual ~MyTestPluginInterface();
CppUnit::Test *makeTest();
};
extern "C" {
__declspec(dllimport) TestPlugInInterface *GetTestPlugInInterface()
{
return new MyTestPluginInterface();
} }
<<end of header>>
<<the cpp>>
#include "stdafx.h"
#include "MyTestPluginInterface.h"
#include <cppunit/extensions/TestFactoryRegistry.h>
MyTestPluginInterface::MyTestPluginInterface()
{}
MyTestPluginInterface::~MyTestPluginInterface()
{}
CppUnit::Test *MyTestPluginInterface::makeTest()
{
CppUnit::Test *myTest = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
return myTest;
}
<<end of cpp>>
Can anyone suggest why there are zero tests being found by the mfc gui test runner??
Cheers
Found my problem. I'd used the wrong macro to register the test with the test suite. All working happily.
I'm having the same problem, i.e no tests are being found.
My project is compiled on a Suse 8.2 Linux using g++ and makefiles. Apparently something goes wrong when placing the object code that contains the suite registration (using the CPPUNIT_TEST_SUITE_NAMED_REGISTRATION macro)
in a seperate static library which is then linked with the main program object code. Because, when all sources are compiled & linked together in 1 step (not using a lib) everything works fine (i.e all tests are 'found').
Anyone any suggestions as to how this can occur?
All help will be greatly appreciated.
Greetings,
Kurt
You have to figure out how to disable dead code stripping in your tools. I'm guessing that what's happening (what usually happens) is that the linker is trying to be "smart" so it's removing objects that aren't referenced anywhere. Unfortunately this is exactly what you're looking for; the objects aren't referenced directly, but their constructors have side effects that make them get referenced.
After examining the 2 binaries (the one that works & the one that doesn't work) with nm it is clear that object code for the test execution is not extracted from the library.
Using ld's -whole-archive option solves the problem.
Thanks for your help.