-2

This post is a continuation to Boost Unit Test Framework with Multiple Sources

When the following piece of code (borrowed from the aforementioned post)

// test_main.cpp
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE Main
#include <boost/test/unit_test.hpp>

// test1.cpp
#define BOOST_TEST_DYN_LINK
#ifdef STAND_ALONE
#   define BOOST_TEST_MODULE Main
#endif
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(test1_suite)

BOOST_AUTO_TEST_CASE(Test1)
{
    BOOST_CHECK(2<1);
}

BOOST_AUTO_TEST_SUITE_END()

// test2.cpp
#define BOOST_TEST_DYN_LINK
#ifdef STAND_ALONE
#   define BOOST_TEST_MODULE Main
#endif
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(test2_suite)

BOOST_AUTO_TEST_CASE(Test1)
{
    BOOST_CHECK(1<2);
}

BOOST_AUTO_TEST_SUITE_END()

is compiled, (as suggested) with

$ g++ test_main.cpp test1.cpp test2.cpp -lboost_unit_test_framework -o tests

How do I achieve this using Boost.Build (to compile and test from multiple sources for Boost Unit Test Framework using Boost.Build)?

Community
  • 1
  • 1
hell_ical_vortex
  • 361
  • 2
  • 11

1 Answers1

0

In order to compile and run the unit test with Boost.Build rule unit-test, create the following Jamfile

unit-test test_all
  : [ glob test*.cpp ] /root//boost_test
  ;

and define the libraries in /home/<user>/user-config.jam as follows

project root ;
lib boost_test : : <name>boost_unit_test_framework ;

Also refer this nabble thread

hell_ical_vortex
  • 361
  • 2
  • 11