
Please don't tell me that I no longer can specify the name of the master test suite.
No. You could. But I found relying on macro is both inconvinient and unhealthy.
On the contrary, I found it most convenient (even though the macro name is a bit misleading). Compare:
--- w/ macro ---
#define BOOST_AUTO_TEST_MAIN "foo" #include <boost/test/auto_unit_test.hpp>
Note: 1 .You are required to put the name in quotes it fales otherwise 2. Marco name is misleading and nonobvios(BTW proper name now is BOOST_TEST_MAIN) 3. It's usually bad idea to give the same entity two different purposes. It backfire one way or another. 4. It's usually preferable to employ nonmacro mechanisms, unless macro provide real advantage.
--- w/o macro ---
#include <boost/test/auto_unit_test.hpp>
#include <boost/test/unit_test.hpp>
boost::unit_test::test_suite* init_unit_test_suite( int, char*[] ) { boost::unit_test::framework::master_test_suite().p_name.value = "foo"; return 0; }
With alternative init API (to became default 1.35 release) it would look like: bool init_unit_test() { framework::master_test_suite().p_name.value = "foo"; return true; } It doesn't look that bad.
---
As a side note, why does the above work? I'm not returning a pointer to a test suite.
Read an update note.
4) BOOST_AUTO_TEST_SUITE names not reported in errors
"Feature not a bug" ;) With confirmation report only master test suite level name gets mentioned
So, I'd like to make a new feature request - having the name of the closest encompassing test suite being reported instead (as the default). Or, even better, having the entire hierarchy reported.
Test suite names gets reported in detailed report format. How would you prefer confirmation reporty should look like?
Using the above example, and adding the following to another file: ---
#include <boost/test/auto_unit_test.hpp>
BOOST_AUTO_TEST_SUITE(bar); BOOST_AUTO_TEST_CASE(baz) { BOOST_FAIL("Flunk!!"); } BOOST_AUTO_TEST_SUITE_END();
---
This is what I currently get:
--- Running 1 test cases... <some path>/bar.cpp(7): fatal error in "baz": Flunk!!
*** 1 failure detected in test suite "foo" ---
I can see that there would be a problem adding the specific test suite name
It could be achived by supplying custop report formatter. Though you will need to make the whole report youself.
to the summary line ("*** ..."), as it assumes only one test suite. How about adding the name to the actual error output:
<some path>/bar.cpp(7): fatal error in "foo::bar::baz": Flunk!!
Currently it's impossible, bur could be aranged. Though I still do not see whi you couldn't change log level.
I also kind of miss the regular CppUnit output; perhaps the "dotting" output during test runs, the error reports, the summary with X tests, Y assertions, Z failures.
You need t ogive more detailes
What would the simplest steps be to provide something similar using Boost.Test? Perhaps some section in the docs for xUnit users - nailing down how to get the same output / summary using Boost.Test.
Most of the output is configurable by submitting custom report/log formatters. Gennadiy