Search code examples
gradlescoverage

How to ignore some class path from gradle scoverage coverage reports?


how testScoverage task can be configured in Gradle Scoverage to exclude some class from test coverage. In sbt scoverage that can be achieved by adding in settings coverageExcludedPackages := ";Reverse.*;.AuthService.;models\.data\..* How to achieve same in gradle scoverage


Solution

  • It's not described in this plugin documentation, but this plugin exposes a Gradle extension named scoverage of type ScoverageExtension that you can use to configure the plugin, see available properties in the extension source code.

    You could configure excluded packages as follow, for example:

    scoverage{
        excludedPackages = ["Reverse.*",".AuthService." , "models.data"]
          // TODO : configure patterns correctly, this is only a dummy example
    }
    

    Note: I did not test this plugin myself, but looking at the source code, this is how it's supposed to work.