XML从Google测试中生成没有显示跳过的测试用例

发布于 2025-01-28 09:03:30 字数 1043 浏览 1 评论 0原文

我正在使用Google测试框架在C ++中进行单元测试。在测试名称之前,我很少使用禁用的测试用例,并且使用GTEST_SKIP()跳过了一些测试。这很好,我可以看到在Teminal日志中被禁用并跳过的测试。问题是当我从测试中生成XML文件时。
我正在使用以下命令。

--gtest_output=xml:/data/TestReport.xml

生成的XML

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="17" failures="7" disabled="3" errors="0" time="57.713" timestamp="1970-01-04T10:31:55" name="AllTests">
<testsuite name="UNITTEST" tests="17" failures="7" disabled="3" errors="0" time="45.713" timestamp="1970-01-04T10:32:04">
<testcase name="Test_1" status="run" result="skipped" time="0" timestamp="1970-01-04T10:32:04" classname="UNITTEST" />
<testcase name="Test_2" status="run" result="completed" time="0.461" timestamp="1970-01-04T10:32:04" classname="UNITTEST" />
<testcase name="Test_3" status="run" result="completed" time="7.089" timestamp="1970-01-04T10:32:05" classname="UNITTEST">

我想指出的是, 是整合所有测试套件的标签测试套件不会跳过属性。 所有测试的合并的标签测试套件也没有跳过属性。但是,测试_1确实显示了跳过的结果。是否有任何配置可以使跳过的计数出现。

谢谢。

I am using google test framework for doing unit testing in c++. I have few test cases which i have disabled using DISABLED_ before test name and some tests are skipped using GTEST_SKIP(). This is working fine and i can see the tests being disabled and skipped in the teminal log. The problem is when i am generating the xml file from the test.
I am using the following command.

--gtest_output=xml:/data/TestReport.xml

The generated XML

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="17" failures="7" disabled="3" errors="0" time="57.713" timestamp="1970-01-04T10:31:55" name="AllTests">
<testsuite name="UNITTEST" tests="17" failures="7" disabled="3" errors="0" time="45.713" timestamp="1970-01-04T10:32:04">
<testcase name="Test_1" status="run" result="skipped" time="0" timestamp="1970-01-04T10:32:04" classname="UNITTEST" />
<testcase name="Test_2" status="run" result="completed" time="0.461" timestamp="1970-01-04T10:32:04" classname="UNITTEST" />
<testcase name="Test_3" status="run" result="completed" time="7.089" timestamp="1970-01-04T10:32:05" classname="UNITTEST">

I would like to point out that the tag testsuites which is a consolidation of all the testsuite does not have an attribute skipped.
The tag testsuite which is a consolidation of all the tests also does not have the attribute skipped. However, the test Test_1 does show the result as skipped. Is there any configuration to make the count of skipped appear.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍白女子 2025-02-04 09:03:30

这可能是版本问题。我正在吐口水,添加了在这里。标签testsuite 跳过为我跳过:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="0" timestamp="2022-05-13T17:38:54.980" name="AllTests">
  <testsuite name="MyTestSuite" tests="3" failures="0" disabled="0" skipped="1" errors="0" time="0" timestamp="2022-05-13T17:38:54.980">
    <testcase name="Test1" status="run" result="skipped" time="0" timestamp="2022-05-13T17:38:54.980" classname="MyTestSuite">
      <skipped message="tests/gtest_demo/fib_test.cc:10
"><![CDATA[tests/gtest_demo/fib_test.cc:10
]]></skipped>
    </testcase>
    <testcase name="Test2" status="run" result="completed" time="0" timestamp="2022-05-13T17:38:54.981" classname="MyTestSuite" />
    <testcase name="Test3" status="run" result="completed" time="0" timestamp="2022-05-13T17:38:54.981" classname="MyTestSuite" />
  </testsuite>
</testsuites>

这是我运行的示例: https://godbolt.org/z/9aw7gryfj

确保您正在运行最新版本。

It's probably a version issue. I'm gussing it was added here. The tag testsuite has skipped for me:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="0" timestamp="2022-05-13T17:38:54.980" name="AllTests">
  <testsuite name="MyTestSuite" tests="3" failures="0" disabled="0" skipped="1" errors="0" time="0" timestamp="2022-05-13T17:38:54.980">
    <testcase name="Test1" status="run" result="skipped" time="0" timestamp="2022-05-13T17:38:54.980" classname="MyTestSuite">
      <skipped message="tests/gtest_demo/fib_test.cc:10
"><![CDATA[tests/gtest_demo/fib_test.cc:10
]]></skipped>
    </testcase>
    <testcase name="Test2" status="run" result="completed" time="0" timestamp="2022-05-13T17:38:54.981" classname="MyTestSuite" />
    <testcase name="Test3" status="run" result="completed" time="0" timestamp="2022-05-13T17:38:54.981" classname="MyTestSuite" />
  </testsuite>
</testsuites>

This is the example that I ran: https://godbolt.org/z/9aW7GrYfj

Make sure you are running the latest release.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文