Using Boost::Test for parallel code

I want to create some tests with boost::unit_test for my parallel (mpi based) C++ codes. I have some basic experiences in using the test framework. For me the main problem, when going to parallel codes, is where to put MPI::Init, such that it is called first. In the test suites I have created there is no main function. Furthermore, does Boost::Test exists correctly (with respect to mpi) when some assertions fail on a subset of the existing ranks?


Boost Test has fixture support, which allows you to perform setup/cleanup per test case, test suite, or globally. Sounds like you should put the call to MPI::Init in a global fixture.

struct MPIFixture {
    MPIFixture() { MPI::Init(); }
    ~MPIFixture() { /* I bet there's a deinit you should call */ }


If you have trouble working with that, or if you are working in a framework that provides its own main function, then you can #define BOOST_TEST_NO_MAIN before including the Boost headers. Then you can invoke boost::unit_test::unit_test_main yourself to run your test suites.

Need Your Help

Jquery Expanding Div MVC

jquery razor

Total noob at jquery and thought id try a simple expanding div. This seems to do nothing. Can anyone explain where i have gone wrong please?

XML vs Text for Non-web development applications

xml regex text

I do alot of systems programming where my apps have no chance of being used to communicate over the web or viewed through a browser. But, there has been some push by management to use XML. For ex...