I am trying to exclude packages and files from the scoverage report.
However it does not exclude the specified files and packaged.
I am doing this:
<excludedPackages>*api.test.*</excludedPackages>
<excludedFiles>.*File.scala</excludedFiles>
Could someone suggest how it works for you ?
Cheers V.
Similar to https://stackoverflow.com/a/44346781/2370679
Add the following to your build.sbt
file:
To exclude packages (e.g. to exclude *api.test.*
and *api.db*
packages):
coverageExcludedPackages := "<empty>;*api.test.*;*api.db*"
You can also use the syntax to exclude files:
coverageExcludedPackages := "*File.scala"
For your specific example, you can try:
coverageExcludedPackages := "*File.scala;*api.test.*"
Reference: https://github.com/scoverage/sbt-scoverage#exclude-classes-and-packages
You seem to be doing this right, though I'm not familiar exactly with the Maven plugin which you seem to be using.
Thing is, when scoverage excludes files, it still compiles the classes in them, but it doesn't instrument them, resulting in a .class
file identical to one which will be produced by compilation without the plugin. This might be confusing you to see .class
files for classes originated in source files you explicitly excluded -- it sure did confuse me -- but this is how the plugin works.
Update:
The Scoverage scalac plugin will try to match file paths to the regex after removing .scala
from them; i.e, omit the .scala
from your regex as it will never match any file pattern.
Also note that the regex is matched against paths and not class names; i.e, use /
instead of \.
. Can't say if this works on Windows (if not then it's a bug with the scalac plugin).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With