Skip to content

Code coverage: exclude specified classes #1749

Open

Description

Is there a way to configure the code coverage tool to exclude certain classes from coverage? I know there's a java.test.coverage property but haven't been able to find any details on how to configure it, other than the appendResult property.

If there is currently no way to do this, it would be great to add it as a new feature.

Activity

  1. ericPavone commented on Feb 14, 2025

    @ericPavone

    i get the same problem, can't exclude target folders from coverage

  2. sterling000 commented on Mar 27, 2025

    @sterling000

    Same problem, I have a few integration test and sample classes with main functions in my project that I don't want to track coverage on because it wouldn't make sense, they are distorting the results.

  3. regis-amaral commented on Jun 4, 2025

    @regis-amaral

    Same problem

  4. pcarterubc commented on Jul 29, 2025

    @pcarterubc
    Author

    Just discovered that jacoco has built-in support for handling this issue. See this post for details. Note that you can also use the annotation to exclude an entire class from coverage.

  5. glektarssza commented on Nov 4, 2025

    @glektarssza
    Contributor

    I've ran into this today and am in the process of submitting a PR to support this functionality. Stand by!

    PR: #1809

  6. github-actions commented on Nov 12, 2025

    @github-actions

    Hi Paul Carter (@pcarterubc), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

    There’s currently no built-in support in vscode-java-test to exclude classes via java.test.coverage. You can work around this at the build tool level:

    • Maven (JaCoCo):

    <plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <configuration>
        <excludes>
          <exclude>com/example/IgnoreMe*</exclude>
        </excludes>
      </configuration>
    </plugin>

    https://www.jacoco.org/jacoco/trunk/doc/maven.html

    • Gradle (JaCoCo):

    jacocoTestReport {
      afterEvaluate {
        classDirectories.setFrom(files(
          classDirectories.files.collect {
            fileTree(dir: it, exclude: ['com/example/IgnoreMe*'])
          }
        ))
      }
    }

    https://docs.gradle.org/current/userguide/jacoco_plugin.html

    If you’d like native support in vscode-java-test, please upvote/comment on the feature request:

    • Code coverage report discussion (feature request)
    #387

    Other references with low confidence

    • Bug: Coverage not shown for subprojects in Explorer and Testing tab – discusses internal handling of coverage results, but doesn’t address exclusion. #1676

    The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

  7. glektarssza commented on Feb 10, 2026

    @glektarssza
    Contributor

    Looks like my PR finally got merged!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions