【问题标题】:How to configure jacoco4sbt with Play Framework 2.3如何使用 Play Framework 2.3 配置 jacoco4sbt
【发布时间】:2015-05-13 09:08:24
【问题描述】:

我决定使用 jacoco4sbt 作为我们 Play 2.3 项目的 Java 代码覆盖工具。我按照jacoco4sbt 的说明进行操作,但由于某种原因,当我执行activator jacoco:coverage 并且没有生成覆盖率报告时,一些测试失败了。当我运行activator test 时,所有单元测试都通过了。在我的 build.sbt 文件中,我有

jacoco.settings parallelExecution in jacoco.Config := false libraryDependencies ++= Seq( javaJdbc, javaEbean, cache, javaWs, "com.google.inject" % "guice" % "3.0", "com.github.fge" % "json-schema-validator" % "2.1.7", "org.openl" % "org.openl.core" % "5.13.2", "org.openl.rules" % "org.openl.rules" % "5.13.2")

但是,当我运行 jacoco:parallelExecution 时,它仍然显示为 true。在我的 plugins.sbt 文件中,我添加了 addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")

当我在激活器中运行 jacoco:report 时,我收到以下错误 (jacoco:report) java.io.FileNotFoundException: C:\users\me\project\target\scala-2.11\jacoco\jacoco.exec (The system cannot find the file specified)

当我运行 about 我得到 ​​p>

[info] This is sbt 0.13.5 
[info] The current project is {file:/C:/Users/me/project/}root 20 15.03.10.04.21.a5de5e0  
[info] The current project is built against Scala 2.11.4 
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, play.Play, play.PlayJava, play .PlayScala, play.twirl.sbt.SbtTwirl, com.typesafe.sbt.jse.SbtJsEngine, com.types afe.sbt.jse.SbtJsTask, com.typesafe.sbt.web.SbtWeb, com.typesafe.sbt.webdriver.S btWebDriver, com.typesafe.sbt.SbtEcho, org.sbtidea.SbtIdeaPlugin, com.typesafe.sbteclipse.plugin.EclipsePlugin, com.typesafe.sbt.SbtNativePackager, com.typesafe .sbt.SbtGit, de.johoop.jacoco4sbt.JacocoPlugin 
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4

我是否需要一个特定的 jacoco 配置文件,如果需要,在哪里? 我注意到执行jacoco:test 可以成功运行测试。之后当我运行jacoco:report 时,我得到了我提到的相同文件未找到错误。

【问题讨论】:

    标签: sbt playframework-2.3 jacoco


    【解决方案1】:

    没有生成 jacoco.exec 文件,因为我的测试失败。为了生成代码覆盖率报告,您不能有任何失败的测试。在我意识到这一点并修复测试后,我能够生成报告。

    【讨论】:

    • 也发生在我身上......来自activator jacoco:cover 的错误消息没有帮助,因为它们给出了完全不相关的错误。
    猜你喜欢
    • 2015-04-25
    • 2015-04-02
    • 2015-01-21
    • 2020-07-07
    • 1970-01-01
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 2016-08-10
    相关资源
    最近更新 更多