I have a Visual Studio
project where I want to do some unit tests with Boost.Test
.
And I have 2 files:
File 1:
#define BOOST_TEST_MODULE FileX
#include <boost/test/unit_test.hpp>
#include <stdio.h>
BOOST_AUTO_TEST_SUITE(test_suite_name)
BOOST_AUTO_TEST_CASE(TestFileX)
{
BOOST_CHECK(true);
}
BOOST_AUTO_TEST_SUITE_END()
And File 2:
#define BOOST_TEST_MODULE XContainer
#include <boost/test/unit_test.hpp>
#include <stdio.h>
BOOST_AUTO_TEST_SUITE(test_suite_name2)
BOOST_AUTO_TEST_CASE(TestXContainer)
{
BOOST_CHECK(true);
}
BOOST_AUTO_TEST_SUITE_END()
When I compile the project I get a link error that's saying that main is already defined.
I noticed that main
file is defined in unit_test.hpp
but I need to include it for the test macros.
How should I add 2 test cases in 2 separate file?
You must use
#define BOOST_TEST_DYN_LINK
in every source file with tests.