Boost unit test detected an error in the wrong test suite

I am learning how to use the Boost test library at the moment, and I cannot get the test suites to work correctly. The following code "test_case_1" crashes, but it is reported as being in the Master Test Suite instead of "test_suite_1".

Does anyone know what I'm doing wrong?

#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>

BOOST_AUTO_TEST_SUITE(test_suite_1);

BOOST_AUTO_TEST_CASE(test_case_1) {
    BOOST_REQUIRE_EQUAL(1, 2);
}

BOOST_AUTO_TEST_SUITE_END();

edit:

Ovanes answer led me to understand the package hierarchy better - in this case test_suite_1 is the subnet of the root package, which is called the “Master Test Suite” by default. The default protocol displays only the root package, which I did not expect from it. I can handle it :)

, BOOST_TEST_MODULE - , :

#define BOOST_TEST_MODULE test_suite_1
#define BOOST_AUTO_TEST_MAIN

#include <boost/test/auto_unit_test.hpp>

BOOST_AUTO_TEST_CASE(test_case_1) {
    BOOST_REQUIRE_EQUAL(1, 2);
}
+3
2

, . , --log_level = all :

Running 1 test case...
Entering test suite "Master Test Suite"
Entering test suite "test_suite_1"
Entering test case "test_case_1"
d:/projects/cpp/test/main.cpp(9): fatal error in "test_case_1": critical check 1 == 2 failed [1 != 2]
Leaving test case "test_case_1"
Leaving test suite "test_suite_1"
Leaving test suite "Master Test Suite"

*** 1 failure detected in test suite "Master Test Suite"

Boost Test Framework.

,

+2

, BOOST_TEST_MODULE, BOOST_AUTO_TEST_MAIN

0

Source: https://habr.com/ru/post/1713361/


All Articles