【问题标题】:Sonarqube Partially covered testsSonarqube 部分覆盖的测试
【发布时间】:2020-02-04 14:50:37
【问题描述】:

Sonarqube 测试覆盖率报告说我的 c++ 语句只被部分覆盖。包含此类语句的非常简化的函数示例如下:

std::string test(int num) {
    return "abc";
}

我的测试如下:

TEST(TestFunc, Equal) {
    std::string res = test(0);
    EXPECT_EQ (res, "abc");
}

Sonarqube 覆盖率报告说返回 stmt 仅被测试部分覆盖(2 个条件中的 1 个)。我想知道我需要测试的其他条件是什么?

我还在报告中看到了以下内容:

Condition to cover: 2
Uncovered Condition: 1
Condition Coverage: 50%

似乎我需要一个测试来涵盖其他情况,但我无法弄清楚那是什么。

【问题讨论】:

    标签: unit-testing sonarqube


    【解决方案1】:

    经过更多研究,这不是 Sonarqube 问题。这个post(及其周围的方法)很可能解释了我的问题的根本原因。

    相关帖子:LCOV/GCOV branch coverage with C++ producing branches all over the place

    【讨论】:

      猜你喜欢
      • 2018-10-18
      • 2021-07-09
      • 2022-07-01
      • 2015-03-13
      • 2015-12-10
      • 2016-09-13
      • 2014-05-04
      • 2015-10-26
      • 2021-03-03
      相关资源
      最近更新 更多