the Compartmented Robust Posix C++ Unit Test system

WITH_TEST_TAG(tagname)

Mark a test with a tag.

Used in: The modifier list of a test definition. See TEST(name, ...)

Set a named tag to a test. If not compiling with a C++11 compiler, the tag must be defined with DEFINE_TEST_TAG(tagname) before use. A test can either be untagged (the default,) or have one tag. It is not possible to attach several tags to a test.

See the command line option -T {select}{/non-critical} / --tags={select}{/non-critical} for how to use tags when running a test program.

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.