Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running unit tests excluding a specific tag in Catch2

Tags:

c++

catch2

Can I run test cases based on "not matching" a particular tag in Catch2?

TEST_CASE("Check the data validity","[Working]"){
  REQUIRE(true);
}

TEST_CASE("Check the input","[InProgress]"){
  REQUIRE(true);
}
TEST_CASE("Validate the response","[NotWorking]"){
  REQUIRE(false);
}

I want to invoke testcases that are not falling in [NotWorking] tag until I finish implementing that functionality.

like image 745
Wander3r Avatar asked Feb 14 '19 15:02

Wander3r


1 Answers

Source: https://github.com/catchorg/Catch2/blob/master/docs/command-line.md#specifying-which-tests-to-run

Test case examples:

thisTestOnly            Matches the test case called, 'thisTestOnly'
"this test only"        Matches the test case called, 'this test only'
these*                  Matches all cases starting with 'these'
exclude:notThis         Matches all tests except, 'notThis'
~notThis                Matches all tests except, 'notThis'
~*private*              Matches all tests except those that contain 'private'
a* ~ab* abc             Matches all tests that start with 'a', except those that
                        start with 'ab', except 'abc', which is included

So in your case add to the command line:

exclude:NotWorking

or

~NotWorking
like image 51
Robert Andrzejuk Avatar answered Nov 14 '22 11:11

Robert Andrzejuk