I have written unit tests using the Boost unit testing framework. When I run them, and a test fails, instead of printing which test case has failed, only the test executable with a failure is printed.
For example, this is my unit test that passes:
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE "Point3D"
#include <boost/test/unit_test.hpp>
#include "point3D.h"
BOOST_AUTO_TEST_CASE(TestDefaultConstructor)
{
Point3D pt;
BOOST_CHECK_EQUAL(pt.X(), 0);
BOOST_CHECK_EQUAL(pt.Y(), 0);
BOOST_CHECK_EQUAL(pt.Z(), 0);
}
make test
produces
Test project /path/to/build
Start 1: point3D_test
1/1 Test #1: point3D_test ..................... Passed 0.01 sec
so we're all good.
But if I change the unit test case to
BOOST_AUTO_TEST_CASE(TestDefaultConstructor)
{
Point3D pt;
BOOST_CHECK_EQUAL(pt.X(), 1); // This should fail
BOOST_CHECK_EQUAL(pt.Y(), 0);
BOOST_CHECK_EQUAL(pt.Z(), 0);
}
the output is:
Test project /path/to/build
Start 1: point3D_test
1/1 Test #1: point3D_test .......................***Failed 0.01 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.01 sec
The following tests FAILED:
1 - point3D_test (Failed)
Errors while running CTest
make: *** [test] Error 8
How can I get the actual test case (e.g. TestDefaultConstructor
) that has the failure? The documentation for this related topic seems to show that case-specific results are possible. How can I do this?
Aucun commentaire:
Enregistrer un commentaire