运行单元测试,但不包括Catch2中的特定标签

时间:2019-02-14 15:10:18

标签: c++ catch2

我可以基于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);
}

我想调用不属于[NotWorking]标记的测试用例,直到完成该功能为止。

1 个答案:

答案 0 :(得分:2)

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

测试案例示例:

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

因此,在您的情况下,请添加到命令行:

exclude:NotWorking

~NotWorking