Hi,
We are starting to expand the number of test modules and are having
some growing pains.
Originally we were using the "single header" variant
included/unit_test.hpp file. Now we have switched
to linking to the dynamic version of the boost test library
and are including auto_unit_test.hpp.
Just unit_test.hpp is fine. Older name is deprecated.
Ok- hopefully that's true for the version mentioned in the subject line.
We have been counting on the Test Tools to automatically register
suites and test cases. This still worked when we just included
unit_test.hpp (instead of included/unit_test.hpp).
However with multiple test modules, init_unit_test_suite is being
defined in each module.
This should work as you expect. Please post simple example illustrating
your issues.
Test1.cpp:
-----
#include "stdafx.h"
#define BOOST_TEST_MODULE foo2
#include
#include
class DefaultFixture {
public:
DefaultFixture()
{
}
~DefaultFixture() {};
};
BOOST_AUTO_TEST_SUITE(foo2)
BOOST_FIXTURE_TEST_CASE(foo2, DefaultFixture)
{
BOOST_CHECK(4 == 4)
}
-----
Test2.cpp:
-----
#include "stdafx.h"
#define BOOST_TEST_MODULE foo
#include
#include
class DefaultFixture {
public:
DefaultFixture()
{
}
~DefaultFixture() {};
};
BOOST_AUTO_TEST_SUITE(foo)
BOOST_FIXTURE_TEST_CASE(foo, DefaultFixture)
{
BOOST_CHECK(4 == 4);
}
BOOST_AUTO_TEST_SUITE_END()
-----
And Link with boost library....
1>TestCase2.obj : error LNK2005: "class boost::unit_test::test_suite * __cdecl init_unit_test_suite(int,char * * const)" (?init_unit_test_suite@@YAPAVtest_suite@unit_test@boost@@HQAPAD@Z) already defined in basic.obj
Googling around, I discovered this cryptic define done in one of the files will fix it:
-----
#define init_unit_test_suite init_auto_unit_test_suite
-----
A strange observation as well....
Take this code:
#include "stdafx.h"
#define BOOST_TEST_MODULE foo
#include
#include
class DefaultFixture {
public:
DefaultFixture()
{
}
~DefaultFixture() {};
};
BOOST_AUTO_TEST_SUITE(foo)
BOOST_FIXTURE_TEST_CASE(foo, DefaultFixture)
{
BOOST_CHECK(4 == 4);
}
BOOST_AUTO_TEST_SUITE_END()
And change BOOST_FIXTURE_TEST_CASE toBOOST_TEST_CASE(foo)... it won't compile:
C:\basic\test2.cpp(21) : error C2882: 'foo' : illegal use of namespace identifier in expression
c:\code\main\test\bora-vmsoft\svga\tests\bat\basic\basic\test2.cpp(22) : error C2448: 'boost::unit_test::make_test_case' : function-style initializer appears to be a function definition
-----
Anyway, thanks for your help. The documentation right now seems to be lacking a little bit in giving clear examples of the different styles in which we are able to do test and suite registration.
Greg