[Cppunit-devel] Test suites that combine stubs and component being stubbed
Brought to you by:
blep
|
From: David R. <dre...@gm...> - 2004-12-10 17:47:39
|
Hi,
I'm looking at ways to combine existing test suites. However one
problem I can see myself running into is with combining a test suite
that uses a stub for component X with a test suite for the real X,
that would mean duplicate symbols for the final link. For the test
suite that uses a stub for X, I suppose one approach could be to have
the stub named differently and in the component that uses X have a
macro for the test build that #defines X to be the stubname instead
but I don't know if I like that approach. e.g. of this below.
TestFixtureForFoo.cpp
void TestFixtureForFoo::testInteractionWithX()
{
Foo f;
CPPUNIT_ASSERT( f.memberFunctionThatInteractsWithX());
}
Foo.cpp
#ifdef CPPUNIT_TEST_BUILD
//re-define so symbols don't clash with the real thing, and Foo's code
needs no change
#defined X XStub
#endif
bool Foo:memberFunctionThatInterfactsWithX()
{
X instanceOfX;
return instanceOfX.doSomething()
}
I'm sure people have gone through the same thing so I'm wondering if
there's a common approach to this ?
|