I just wonder, is there a way to track which test/test_suite is started/stopped to log that event into my log file so I know in the log file which events correspond to which test.
From the very beginning I just added a line to the test case like following. And it worked fine.
BOOST_AUTO_TEST_CASE(testRecovery)
{
SPDLOG_INFO("MyComponentTests::testRecovery");
// ...
Once I’ve reached 20+ tests cases it became hard to manage that approach. I’ve started to forgetting to add that line.
Later I’ve found boost::unit_test::unit_test_log_formatter
and I’ve created a TestCasesTracker
class that does a job:
class TestCasesTracker : public boost::unit_test::unit_test_log_formatter
{
void test_unit_start(std::ostream&, boost::unit_test::test_unit const& tu) override
{
// ...
SPDLOG_INFO("==> {}", tu.p_name);
Unfortunately this approach does not work for me, as it completely takes over all the logging so --log_level=test_suite
does not work. Also I used that approach to integrate my tests into the TeamCity. So when I enable my TestCasesTracker
, TeamCity become blind on which tests are executed.
Therefore my question, is there non-intrusive way to catch test start/stop events?