1 year ago

#77059

test-img

kim nguyen

scoverage exclude packages for test vs integration test

in my build.scala i have

coverageExcludedPackages in ThisBuild := ".*dao.*"

which works great for excluding the package from coverage however i want to be able to exclude and include based on the type of tests I'm running.

For instance i run sbt test and sbt it:test my test is mainly unit test where as it:test has integration test that talks to the DB and i want that to show up in the coverage report when running sbt coverage it:test && sbt coverageReport but not be in the report for sbt coverage test && sbt coverageReport

there are some settings like

lazy val testSettings = Seq(
  libraryDependencies ++= Seq(
    "org.scalatest" %% "scalatest" % "3.0.0" % "smoke,it,test",
    "org.mockito" % "mockito-core" % "2.5.7" % "test"
  ),
  testOptions in Test += Tests.Argument("-oDF"),
  coverageExcludedPackages in Test := ".*dao.*"
)

where i tried to move the exclusion so that its only part of the test settings and not part of the it:test settings but it seems then to ignore the exclusion all together when I try that.

scala

build

sbt

scoverage

0 Answers

Your Answer

Accepted video resources