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.
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
For your usecase of including the test, but expecting some assertions to fail you would be better off with the [!mayfail]
tag.
See here :
[.mayfail] - doesn't fail the test if any given assertion fails (but still reports it), This can be useful to flag a work-in-progress. or a known issue that you don't want to immediately fix but still want to track in your tests.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.