| the Compartmented Robust Posix C++ Unit Test system |
|
|---|
Introduce a tag for use by tests.
Used in: Global scope with older C++ compilers
In C++98 a tag has the same naming rules and visibility as a C++ type[4].
See the command line option
-T
{select}{/non-critical}
/
--tags={select}{/non-critical}
for how to use
tags when running a test program.
![]() | Tip |
|---|---|
If you compile your test program as C++11,
DEFINE_TEST_TAG() is not needed.
|
Example. The following test program:
#include <crpcut.hpp>
DEFINE_TEST_TAG(known_bug);
DEFINE_TEST_TAG(uncertain);
TEST(untagged)
{
FAIL << "the critical error";
}
TEST(buggy, WITH_TEST_TAG(known_bug))
{
FAIL << "this is a known issue we don't want to be bothered with right now";
}
TEST(we_dont_know_the_expected_behaviour, WITH_TEST_TAG(uncertain))
{
FAIL << "Was this right or wrong?";
}
int main(int argc, char *argv[])
{
return crpcut::run(argc, argv);
}
Shows how tags are defined and used by tests. Running it with
--tags=-known_bug/uncertain yields:
FAILED!: untagged
phase="running" --------------------------------------------------------------
samples/test_tag.cpp:35
the critical error
-------------------------------------------------------------------------------
===============================================================================
FAILED?: we_dont_know_the_expected_behaviour
phase="running" --------------------------------------------------------------
samples/test_tag.cpp:45
Was this right or wrong?
-------------------------------------------------------------------------------
===============================================================================
3 test cases selected
tag run passed failed
?uncertain 1 0 1
Sum Critical Non-critical
FAILED : 2 1 1
UNTESTED : 1
Which shows two tests run, both failed, but one as non-critical. The test buggy is not run since all tests tagged known_bug were filtered out.