gpt4 book ai didi

java - 如何在 sonarqube 中为最终类的私有(private)构造函数提供测试覆盖率?

转载 作者:行者123 更新时间:2023-11-30 06:45:39 25 4
gpt4 key购买 nike

我有一个最终的 util 类,我添加了一个私有(private)构造函数来隐藏默认的公共(public)构造函数。我如何使用 jacoco 覆盖率报告在 sonarqube 中获取此类的覆盖率并在 Jenkins 中构建?

public final class Util {

// My contructor
private Util() {
super();
}
}

最佳答案

根据 JaCoCo changelog从 JaCoCo 版本 0.8.0 开始,自动过滤掉此类私有(private)空无参数构造函数。变更日志还指出:

Tools that directly read exec files and embed JaCoCo for this (such as SonarQube or Jenkins) will provide filtering functionality only after they updated to this version of JaCoCo.

Announcement of release of JaCoCo version 0.8.0状态:

Tools that directly read exec files (which is not a final report) and embed JaCoCo for generation of report will provide filtering functionality only after they updated to this version of JaCoCo. So please follow/wait/etc respective vendors such as

Reports generated by corresponding version (0.8.0) of integrations developed as part of JaCoCo project by us (Ant Tasks, Maven Plugin and Command Line Interface) provide filtering functionality.

截至今天(2018 年 1 月 30 日):

关于java - 如何在 sonarqube 中为最终类的私有(private)构造函数提供测试覆盖率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48513809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com