テストを発見して分析するための sbt-scoverage を取得できません。かなり良いテスト カバレッジ (少なくとも 80%) が必要です。すべてのテストが実行され、問題なくパスします。しかし、調査レポートでは、ほぼゼロのカバレッジ (~ 3%) が示されています。
私が思いつく唯一のことは、specs2 (および scalacheck) を使用していることです。私が見たほとんどの例では、ScalaTest を使用しています。
例: models パッケージには 4 つのクラスがあります。テスト結果は完全にテストされていることを示していますが、カバレッジはゼロです。
[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
しかし、scoverage が確実に実行されていることがわかります。
[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]
しかし、カバレッジ レポートは明らかに、私たちがテストしているクラスをピックアップしていません。
[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
レポートを表示すると、モデル パッケージの 4 つのクラスが完全にテストされていないことがわかります。
built.sbt には次のものがあります。
coverageEnabled := true
coverageMinimum := 80
coverageFailOnMinimum := true
明らかに、上記の設定があり、scoverage がテストを見つけられないため、ビルド エラーが発生します。
[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