Boost logo

Boost :

Subject: Re: [boost] Boost_Test: Initialize fixture only once
From: Dmytro Ovdiienko (dmitriy.ovdienko_at_[hidden])
Date: 2010-03-01 15:21:33


Hello Rhys,

What did you mean "BOOST_FIXTURE_TEST_SUITE per [1]"?

I created test application:

#define BOOST_TEST_MODULE test

#include <boost/test/unit_test.hpp>
#include <iostream>

class Fixture
{
public:
Fixture()
{
std::cout << "Long time initialization" << std::endl;
}
};

BOOST_FIXTURE_TEST_SUITE( default_engine, Fixture )

BOOST_AUTO_TEST_CASE( test_1 )
{
}
BOOST_AUTO_TEST_CASE( test_2 )
{
}

BOOST_AUTO_TEST_SUITE_END()

Below is output:

Running 2 test cases...
Entering test suite "test_application"
Entering test suite "default_engine"
Entering test suite "inner_suite"
Entering test case "test_1"
Long time initialization
Test case test_1 did not check any assertions
Leaving test case "test_1"
Entering test case "test_2"
Long time initialization
Test case test_2 did not check any assertions
Leaving test case "test_2"
Leaving test suite "inner_suite"
Leaving test suite "default_engine"
Leaving test suite "test_application"

As you can see "Long time initialization" string appears twice.

On 1 March 2010 21:49, Rhys Ulerich <rhys.ulerich_at_[hidden]> wrote:

> > I have set of test_suites. Every test_suite consists of a bunch of
> > test_cases. Every test case should be initialized before execution.
> >
> > So, I created Fixture for every test_suite. The problem is Fixture
> > initialization takes a lot of time and boost creates it for every
> test_case
> > (not for every test_suite)
>
> Are you using BOOST_FIXTURE_TEST_SUITE per [1]? That should run once
> per test suite.
>
> - Rhys
>
> [1]
> http://www.boost.org/doc/libs/1_42_0/libs/test/doc/html/utf/user-guide/fixture/test-suite-shared.html
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
Овдиенко Дмитрий
e-mail: dmitriy.ovdienko_at_[hidden]
skype: dmitriy.ovdienko_at_[hidden]
mobile: +38050-1909731

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk