Jacoco将类别从报告中排除 [英] Jacoco exclude classes from report

查看:747
本文介绍了Jacoco将类别从报告中排除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 http://www上使用该示例. eclemma.org/jacoco/trunk/doc/examples/java/ReportGenerator.java

我想从报告生成中排除一些类.我认为必须在分析器中设置它,但是我可以找到一个示例.

I would like to exclude some classes from the report generation. I assume it has to be set in the Analyzer but I could find an example.

推荐答案

  1. 您可以声明一个新的构造函数,该构造函数接受另一个数组列表参数(请勿更改以前的构造函数,因为其他类正在使用它).

  1. You can declare a new constructor that takes another array list argument(Do not change the previous constructor as other classes use it).

public Analyzer(final ExecutionDataStore executionData,
        final ICoverageVisitor coverageVisitor, ArrayList<String> excludeClassPathArrayList) {
this.executionData = executionData;
this.coverageVisitor = coverageVisitor;
this.stringPool = new StringPool();
this.excludeClassPathArrayList = excludeClassPathArrayList;
}

  • 然后在ContentTypeDetector.CLASSFILE:中修改方法analyzeAll(final InputStream input, final String location),您可以这样做,如果位置在arrary列表中包含排除类路径,请像对待其他所有内容类型(return 0)一样忽略它们.

  • Then modify method analyzeAll(final InputStream input, final String location), in ContentTypeDetector.CLASSFILE:, you can do like this, if location contains exclude class path in arrary list, ignore them just like all other content types(return 0).

    mvn clean install重新编译jacoco源代码.

    mvn clean install to recompile the jacoco source code.

    您可以看到被排除的类也被排除在生成的报告之外. 由于实现非常简单,因此我不提供代码示例.

    You can see excluded classes also exclude from generated report. As the implementation is very simple so I do not provide code example.

    这篇关于Jacoco将类别从报告中排除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆