Boost logo

Boost Users :

Subject: [Boost-users] [test] Passing parameters to fixtures
From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2008-09-15 07:20:58


Hello,

to set up and tear down database connections for unit tests, I need
something like parametrized test fixtures.

Up to now (using an old version of Boost.Test) I was creating a customized
test suite (by deriving from test_suite) and performed the connection
handling during construction/destruction of the customized test suite.

As the latest Boost.Test now has explicit support for test fixtures, I was
looking at how I could replace my old approach by using a test suite fixture.

The fixture would need to look something like this:

struct F {
   F(string db_name) { connect to db_name }
   ~F() { disconnect from db_name }
};

Now, the Boost.Test documentation tells me that a fixture is supposed to be
used like this: BOOST_FIXTURE_TEST_SUITE( s, F )

So there doesn't seem to be a way of passing parameters to the constructor
of the fixture. Is there any? Or is there any other way to obtain a
parametrized fixture? Or should I just keep on using customized test suites?

TIA, Markus


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net