
Hello All, I have a question about boost test. Please help. 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) How to solve this? Best regards. Dima

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/fixtu...

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@gmail.com> 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/fixtu... _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Овдиенко Дмитрий e-mail: dmitriy.ovdienko@gmail.com skype: dmitriy.ovdienko@gmail.com mobile: +38050-1909731

Rhys Ulerich 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.
No. This is not the case. BOOST_FIXTURE_TEST_SUITE (as described in docs) serve different purpose. It allows to specify fixture once per suite for all test cases in test suite. At the moment per-suite fixture is not implemented (the only one actually). The only recommendation I have for you is to either use GLOBAL_FIXTURE or use the first test case in a suite as a setup. Gennadiy

Gennadiy, Thanks for reply. I cannot create first test_case as startup because boost performs test_cases randomly. Also I cannot use GLOBAL_FIXTURE because I have several test_suites and they requires different Fixtures. On 1 March 2010 22:44, Gennadiy Rozental <rogeeff@gmail.com> wrote:
Rhys Ulerich 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.
No. This is not the case. BOOST_FIXTURE_TEST_SUITE (as described in docs) serve different purpose. It allows to specify fixture once per suite for all test cases in test suite.
At the moment per-suite fixture is not implemented (the only one actually). The only recommendation I have for you is to either use GLOBAL_FIXTURE or use the first test case in a suite as a setup.
Gennadiy
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Овдиенко Дмитрий e-mail: dmitriy.ovdienko@gmail.com skype: dmitriy.ovdienko@gmail.com mobile: +38050-1909731

Dmytro Ovdiienko wrote: Please do not top post.
I cannot create first test_case as startup because boost performs test_cases randomly.
Not exactly. Within the same test file the test cases are executed in the order you see them in the file (unless you intentionally randomize the order). If you have test cases in multiple test files - yes in this case order is not defined.
Also I cannot use GLOBAL_FIXTURE because I have several test_suites and they requires different Fixtures.
You can always split the test module into several running single test suite. Gennadiy
participants (3)
-
Dmytro Ovdiienko
-
Gennadiy Rozental
-
Rhys Ulerich