Boost logo

Boost Users :

Subject: Re: [Boost-users] [UTF] Accessing global fixture members within tests
From: Simon Pickles (sipickles_at_[hidden])
Date: 2010-01-04 17:12:58


Simon Pickles <sipickles <at> googlemail.com> writes:

>
> Simon Pickles wrote:
> > Simon Pickles wrote:
> >> Hi
> >>
> >> I am using the Unit Test Framework to test my use of boost.python. I
> >> am using a global fixture to initialize the python intepreter a
> >> single time (rather than before each test).
> >>
> >> My problem is I would like to use the Python initialising class in my
> >> tests, and I can't figure out how to do this. I don't want to use
> >> normal fixtures since each test would call initialize the
> >> interpreter, causing problems.

Boost.Test does not provide means to do this directly. You can alsays
mimic some
kind of singleton though:

struct GlobalFixure {
   GlobalFixure*& instance() { static GlobalFixure* s_inst = 0; return
s_inst; }

   GlobalFixure()
   {
       instance() = this;
       ...
   }
};

...

GlobalFixure::instance().m_member.do_something();

#################

Is this approach used as a global fixture or a test fixture?

Thanks Simon


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