【问题标题】:Code coverage with Sonar : % code coverage not coherentSonar 的代码覆盖率:% 代码覆盖率不连贯
【发布时间】:2012-06-30 22:21:56
【问题描述】:

我有一个关于声纳的Code coverage 问题。

在这个例子中:

 public static void apply(Person person) {
        if (person != null) {
            callApply(person);
        }
    }

在我的声纳Code coverage 中,我得到以下结果:

if (person != null) => hit=(10) % = (75%)
callApply(person); => hit(10) % =()

我不明白为什么在相同的命中数下,覆盖率是 75%?为什么我在调用 callApply 方法时没有任何值覆盖率

我认为这个版本的 Sonar 使用 Jacoco 作为覆盖代码。

谢谢。

【问题讨论】:

    标签: code-coverage sonarqube


    【解决方案1】:

    首先,Sonar 默认使用 Cobertura(JaCoCo 将是 Sonar 3.2 中的默认版本,将于 2012 年夏季发布)。

    那么,是什么让您认为在第一行可以获得 75% 的覆盖率,而在第二行则什么都没有?

    【讨论】:

    • Sonar Corverage 的结果,是不是因为没有使用参数 person == null 进行测试?
    猜你喜欢
    • 2012-06-11
    • 2012-12-22
    • 2014-03-26
    • 1970-01-01
    • 1970-01-01
    • 2016-11-08
    • 2011-07-26
    • 2018-01-11
    • 1970-01-01
    相关资源
    最近更新 更多