sbt-scoverage + specs2不工作;分析期间未发现任何测试

时间:2016-08-25 08:11:17

标签: specs2 scoverage

我无法获得发现和分析我们的测试的sbt-scoverage。我们应该有很好的测试覆盖率(至少80%);所有测试运行并通过罚款。但是scoverage报告显示几乎没有覆盖率(~3%)。

我唯一能想到的是,我们正在使用specs2(以及scalacheck)。我见过的大多数例子都使用ScalaTest。

例如:我们在模型包中有四个类。它们显示零覆盖率,即使测试结果显示它们已经过彻底测试:

null

但是我看到scoverage肯定在运行:

[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

但覆盖率报告显然没有找到我们正在测试的课程:

[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]

查看报告时,我看到模型包中的四个类显示完全未经测试。

我们在built.sbt中有以下内容:

[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

显然,由于我们有上述设置,并且因为scoverage无法找到测试,我们会遇到构建失败:

coverageEnabled := true

coverageMinimum := 80

coverageFailOnMinimum := true

0 个答案:

没有答案