简体   繁体   English

jacoco 在覆盖率报告中显示过滤后的代码

[英]jacoco showing filtered code in the coverage report

I have added a filter via annotation to exclude a method from jacoco coverage as mentioned here .我已经通过注释添加了一个过滤器,以从 jacoco 覆盖范围中排除一个方法,如此所述。

But when I see the jacoco html report for coverage I see the filtered method being shown in red as not covered.但是当我看到 jacoco html 覆盖报告时,我看到过滤后的方法以红色显示为未覆盖。 Please check the attached screenshot.请检查随附的屏幕截图。 Is this expected?这是预期的吗?

在此处输入图像描述

Annotation code looks like below注释代码如下所示

package com.spotnana.common;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ExcludeFromJacocoGeneratedReport {}

Jacoco Version - 0.8.8雅可可版 - 0.8.8

This has been answered in jacoco mailing list .这已在jacoco 邮件列表中得到答复。

Ok.好的。 In this case what you see is the code of the lambda body.在这种情况下,您看到的是 lambda 主体的代码。 Technically the compiler creates a method for it which is not excluded.从技术上讲,编译器为它创建了一个不被排除的方法。 I'm afraid this is a limitation of the @Generated annotation.恐怕这是@Generated 注释的限制。

get() method is excluded. get()方法被排除在外。 But compiler internally created a method for lambda which is shown in red in the class level report.但是编译器在内部为 lambda 创建了一个方法,该方法在类级别报告中以红色显示。 This seems to be a limitation of the jacoco @Generated annotation.这似乎是 jacoco @Generated注释的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM