Skip to content

Add method filter ExcludeFromCodeCoverage - #675

Closed
philieu wants to merge 1 commit into
jacoco:masterfrom
philieu:exclude_from_code_coverage_filter
Closed

philieu wants to merge 1 commit into
jacoco:masterfrom
philieu:exclude_from_code_coverage_filter

Conversation

@philieu

@philieu philieu commented Apr 18, 2018

Copy link
Copy Markdown

This PR is to allow filter methods that are annotated with a class named ExcludeFromCodeCoverage. The Java package of the class is not important.
It will allow the end users the flexibility to create this annotation class themselves and use it to filter out methods from code coverage.

Ref. #14

@jhulfikarali

Copy link
Copy Markdown

Is this PR planned for next Jacoco release? This will allow us to focus more on Service testing.

@philieu

philieu commented Feb 7, 2019

Copy link
Copy Markdown
Author

Hi @Godin,

Is there anything I can do to move this PR forward?

As mentioned in another thread, it was created with the following scenario in mind:

  • A build would fail if the code coverage is not 100%
  • There is an ability to exclude certain parts of the code via annotations or comments
  • What is being excluded is clear and right there in pull requests
  • The team can then discuss the merit and reason why certain code is being excluded

In our case, the issue with percentage-based code coverage quality gate is that it is often not clear where the non-covered code is (unless one go through the report in details) and people can often trick coverage (e.g. write tests for the trivial parts but ignore the important bit).
Also, we can already "cheat" by using the lombok.Generated or other "well-known" annotations. It's just not nice having to use that for the above purpose.

Cheers.

@anthonypt87

Copy link
Copy Markdown

Upvoting this. Getting this out would be great. People are misusing lombok.generated to get this functionality (https://stackoverflow.com/questions/47824761/how-would-i-add-an-annotation-to-exclude-a-method-from-a-jacoco-code-coverage-re)

@arouel

arouel commented Feb 6, 2020 •

Copy link
Copy Markdown

@philieu can you update the PR and resolve the conflicts?
@Godin what is blocking you to bring that into a release soon? How can we help you?

@philieu

philieu commented Feb 8, 2020

Copy link
Copy Markdown
Author

@arouel I'm happy to spend time to update the PR and resolve the conflicts. However, given that this PR is from April 2018, I don't think the author is interested in this feature or intent to merge this PR.

@arouel

arouel commented Feb 18, 2020

Copy link
Copy Markdown

@philieu thank you for the update. I'm really curious what @Godin thinks about it?

@ocind

ocind commented Mar 3, 2020

Copy link
Copy Markdown

@Godin @marchof I was hoping to have this feature for Jacoco! Do we have some design concerns regarding this feature? Or you are currently simply too busy to look into this? Do let us know how we can help!

@marchof

marchof commented Apr 2, 2020

Copy link
Copy Markdown
Member

@philieu Thanks for this pull request! After internal discussions we decided that we will not support manual exclusion. We assume that this has a long tail of more feature requests and bugs:

  • Users will expect to have tags for more places: Classes, parts of methods (e.g. catch blocks)
  • Users will ask for show excluded code separately in reports
  • The implementation proposed by you does not work for lambda bodies in the annotated methods.

@philieu

philieu commented Apr 7, 2020

Copy link
Copy Markdown
Author

@marchof Thanks for the message. I can understand where you are coming from.
I can see you already had / will have a long tail of user requests regarding Lombok, Groovy or whatever code generation tools... for now and in the future.
My point is that instead of that, why don't we have the flexibility to specify the annotation exclusion at project config and support anything in the code that can be annotated. Something like this: https://github.com/tonerdo/coverlet/blob/master/Documentation/MSBuildIntegration.md#attributes

Anyway, thanks a lot for you and everyone's effort in building the tool. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Awaiting triage

Development

Successfully merging this pull request may close these issues.

7 participants