Lombok generated code can not be ignored on coverage

一个人想着一个人 提交于 2019-12-11 12:04:39

问题


Here I asked the question:

Lombok, use only getter setter not equals or tostring

I did not want to comment there, because it was very old.

What I want is, I want the code which is generated by lombok to be ignored during coverage of inteljidea and also sonar.

As suggestion in my previous question that I linked , I added this

config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true

I added this to root ,then rebuilded recoveraged.

But for that class

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(parent = BaseApiResponse.class)
public class SaveObligation extends Base{

    @ApiModelProperty(required = true)
    List<LegalObligationDTO> legalObligations;


    public SaveLegalObligatione(String id, List<LegalObligationDTO> legalObligations) {
        super(id, true);
        this.legalObligations = legalObligations;
    }
}



inteljidea shows all green (which means covered) except those lines:

@Data
@EqualsAndHashCode(callSuper = true)

because of lombok I guess.

What can I do for this?

Also , i tried this

config.stopBubbling = true
lombok.addJavaxGeneratedAnnotation = true
lombok.addLombokGeneratedAnnotation = true

For intelj, i dont use different tool coverage. Its own coverage.

By the way, intelj shows like that. But also the code is going to sonarqube so also there will be analysed for coverage.

This is buildgradle

    compileOnly 'org.projectlombok:lombok:+'

回答1:


Lombok works in compile time. For more information see Here for example

So that the bytecode already contains Lombok generated transformations.

Coverage tools, on the other hand, usually work in runtime performing bytecode manipulation).

So, it doesn't make sense to configure Lombok to exclude certain code in coverage, but rather depends on the coverage tool of your choice.

Sonar works at the later phase by gathering reports generated by the coverage tools and sending them to Sonar server.

So I think you should check whether its possible to configure your code coverage tool.

Having said that, probably this code should be called in unit tests - implicitly, not directly, I'm not suggesting unit-testing of lombok generated code.



来源:https://stackoverflow.com/questions/52736045/lombok-generated-code-can-not-be-ignored-on-coverage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!