[Boost.Test] [1.38] Automated test suie registration with muti-file-test-modules

Hi, We are starting to expand the number of test modules and are having some growing pains. Originally we were using the "single header" variant included/unit_test.hpp file. Now we have switched to linking to the dynamic version of the boost test library and are including auto_unit_test.hpp. We have been counting on the Test Tools to automatically register suites and test cases. This still worked when we just included unit_test.hpp (instead of included/unit_test.hpp). However with multiple test modules, init_unit_test_suite is being defined in each module. I am looking for clear documentation on what to do. This seems like the closest thing: http://www.boost.org/doc/libs/1_31_0/libs/test/doc/components/unit_test_fram... However following those directions exactly when trying to use multiple test modules (in a single executable) and only one BOOST_AUTO_TEST_MAIN still results in init_unit_test_suite being multiply defined. I would like multiple test suites, although the documentation for this declares that there is a single global test suite. I apologize if this is well documented somewhere, but after an hour of googling I have to ask. Greg

Greg Christopher
Just unit_test.hpp is fine. Older name is deprecated.
This should work as you expect. Please post simple example illustrating your issues.
I would like multiple test suites, although the documentation for this declares that there is a single global test suite.
You can have multiple test suite under the master test suite. Gennadiy

Ok- hopefully that's true for the version mentioned in the subject line.
Test1.cpp:
-----
#include "stdafx.h"
#define BOOST_TEST_MODULE foo2
#include

Steven Watanabe
Don't #define BOOST_TEST_MODULE in more than one translation unit.
This is covered in docs I believe. BOOST_TEST_MODULE has similar effect as BOOST_TEST_MAIN, but also define the name of the master test suite Gennadiy

Thanks for clearing this up...
Since I don't really need to define the name of the master test suite, I will not use BOOST_TEST_MODULE. As it turns out, that still does not yield a working example. I then have no init_unit_test_suite() defined. By messing around, I find that defining BOOST_AUTO_TEST_MAIN fixes the problem. Looks like I need to do that in some module? I thought that the main program would be pulled out of the library if I didn't provide one. While that may be true, init_unit_test_suite is not defined. So may I assume that for a fully automated situation with multiple test modules, the right approach is simply to insure that BOOST_AUTO_TEST_MAIN is defined in one module? Thanks again, Greg

Greg Christopher
Please post an example and how you build it.
defined. By messing around, I find that defining BOOST_AUTO_TEST_MAIN fixes the problem. Looks like I need to do that in some module?
No. BOOST_AUTO_TEST_MAIN is deprecated and should not be required.
It may not have to be defined it you are using shared library variant of UTF. Gennadiy

The example is basically the same example that was posted earlier:
Test1.cpp:
#include "stdafx.h"
#define BOOST_TEST_MAIN Yes // Remove this line and we stop working
#include

file1.cpp
#include

Hi folks, I am wondering what "non random" means (--random-0). We are seeing the test framework behave such that with --random-0, it seems to do the tests in an order and stick with that order, but I'm not sure how it's deciding the order. If we re-link the test program, it seems to do them in a different order. I would like to figure out how to make this deterministic without losing the benefit of not having to create my own test execution driver. I would think that non random would be in alphabetical order of test_case_name (we are doing auto registration) but that's not what we're seeing. Non-random seems to indicate maybe some kind of static initialization order, which is random. Thanks for any help. Greg

AMDG Greg Christopher wrote:
You are correct that the order is effectively the static initialization order. This is not completely random. Test cases in the same translation unit should be executed in order. In Christ, Steven Watanabe P.S. Please start a new thread instead of replying to an existing thread.

Hi folks, As mentioned in thread below, test cases on boost.test may be being run based on static initialization. However, we are seeing them run in different order with each new link- perhaps because Microsoft is intentionally changing the way things fall in memory? In the past I had created a test framework with auto-registration. In that framework, at static initialization time, objects registered themselves with a global parent object that had a container that was alphabetically sorted. Tests always ran in the same order, even if files were moved around in the project or makefile. At this point my tests aren't even running the same way when I recompile the same cpp file (there is only one cpp file in this test). I guess I'm down to two questions: 1) does this sound like a good feature request, and if so how do I file it? 2) for now what's the shortest path to what I want while retaining auto-registration. Thanks, Greg

Greg Christopher
These is something wrong going on here. The order should be well defined in this case. Are you sure you do not have 'random' set through either using CLA or environment? Can you create simple example illustrating the issues and provide details of your configuration? Gennadiy

Greg Christopher wrote:
And change BOOST_FIXTURE_TEST_CASE toBOOST_TEST_CASE(foo)... it won't compile:
Correct name is BOOST_AUTO_TEST_CASE. BOOST_TEST_CASE is used with manual test case registration. Gennadiy
participants (4)
-
Ahmed Badran
-
Gennadiy Rozental
-
Greg Christopher
-
Steven Watanabe