I am unable to get sbt-scoverage to discover and analyze our tests. We should have pretty good test coverage (at least 80%); all tests run and pass fine. But the scoverage report shows nearly zero coverage (~ 3%).
The only thing I can think of, is that we are using specs2 (and also scalacheck). Most of the examples I've seen use ScalaTest.
For example: We have four classes in the models package. They are showing zero coverage, even though the test results show that they have been tested thoroughly:
[info] Compiling 5 Scala sources to /Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/test-classes...
[info] TestCreditModel
[info] + Given a credit
[info] When validation is performed
[info] Then credits between 1 and 60 should be acceptable
[info] + And credits less than 1 or greater than 60 should not
[info]
[info] + Given a category and attribute credits
[info] When validation is performed
[info] Then we should get validated category credits
[info] + And we should get validated attribute credits
[info] + And invalid category credits should not pass validation
[info] + And invalid attribute credits should not pass validation
[info]
[info] Total for specification TestCreditModel
[info] Finished in 86 ms
[info] 6 examples, 600 expectations, 0 failure, 0 error
[info]
[info] TestCategoryModel
[info] + Given a well formed category
[info] When validation is performed
[info] Categories with good abbreviations and descriptions should be valid
[info] + And those with invalid abbreviations should not
[info] + And those with invalid descriptions should not
[info]
[info]
[info] Total for specification TestCategoryModel
[info] Finished in 167 ms
[info] 3 examples, 300 expectations, 0 failure, 0 error
But I see scoverage is definitely running:
[info] Compiling 11 Scala sources and 1 Java source to /Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/classes...
[info] [info] Cleaning datadir [/Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/scoverage-data]
[info] [info] Beginning coverage instrumentation
[info] [info] Instrumentation completed [31 statements]
[info] [info] Wrote instrumentation file [/Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/scoverage-data/scoverage.coverage.xml]
[info] [info] Will write measurement data to [/Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/scoverage-data]
But the coverage report is clearly not picking up the classes that we are testing:
[IDC] $ coverageReport
[info] Waiting for measurement data to sync...
[info] Reading scoverage instrumentation [/Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/scoverage-data/scoverage.coverage.xml]
[info] Reading scoverage measurements...
[info] Generating scoverage reports...
[info] Written Cobertura report [/Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/coverage-report/cobertura.xml]
[info] Written XML coverage report [/Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/scoverage-report/scoverage.xml]
[info] Written HTML coverage report [/Users/zbeckman/Projects/Accenture/Trident_IDC_Training/target/scala-2.11/scoverage-report/index.html]
[info] Statement coverage.: 3.23%
[info] Branch coverage....: 100.00%
[info] Coverage reports completed
[error] Coverage is below minimum [3.23% < 80.0%]
[trace] Stack trace suppressed: run last *:coverageReport for the full output.
[error] (*:coverageReport) Coverage minimum was not reached
[error] Total time: 1 s, completed Aug 25, 2016 1:11:27 PM
When viewing the report, I see the four classes in the models package show completely untested.
We have the following in our built.sbt:
coverageEnabled := true
coverageMinimum := 80
coverageFailOnMinimum := true
Obviously, since we have the above settings, and since scoverage is failing to find the tests, we get a build failure:
[error] Coverage is below minimum [3.23% < 80.0%]
[error] (*:coverageReport) Coverage minimum was not reached
[error] Total time: 1 s, completed Aug 25, 2016 1:39:12 PM