【发布时间】:2017-08-03 19:57:18
【问题描述】:
我有一个 SBT(Play Framework)多项目应用程序设置,如下所示。所有子模块都在modules 下,但涵盖所有子模块的所有测试用例都在“根”项目中。
|-application
|-src
|-conf
|-modules
| |-proj1
| | |-src
| | |-conf
| | |-target
| |-proj2
| | |-src
| | |-conf
| | |-target
| |-proj3
| | |-src
| | |-conf
| | |-target
| |-proj4
| |-src
| |-conf
| |-target
|-test
| |-src //I have test cases of all other projs here
|-build.sbt
|-plugins.sbt
我的build.sbt 看起来像这样。
name := """my-proj"""
lazy val IntegrationTest = config("it") extend(Test)
lazy val commonSettings = jacoco.settings ++ itJacoco.settings ++ Seq(
organization := "me.abc",
version := "0.1.0",
scalaVersion := "2.11.7",
crossPaths := false,
routesGenerator := InjectedRoutesGenerator
)
lazy val appDependencies = Seq(
cache,
"org.mockito" % "mockito-all" % "1.10.19"
)
lazy val scalacheck = "org.scalacheck" %% "scalacheck" % "1.13.4"
lazy val aaRoot = (project in file(".")).configs(IntegrationTest).settings(commonSettings: _*).settings(
libraryDependencies ++= appDependencies,
libraryDependencies += scalacheck % Test,
parallelExecution in Test := false,
javaOptions in Test += "-Dconfig.file=conf/" + Option(System.getProperty("test.config")).getOrElse("application") + ".conf",
parallelExecution in jacoco.Config := false,
jacoco.includes in jacoco.Config := Seq("./modules/*/target/classes/com/me/**/*"),
parallelExecution in itJacoco.Config := false,
itJacoco.includes in itJacoco.Config := Seq("./modules/*/target/classes/com/me/**/*"),
Keys.fork in itJacoco.Config := true,
Keys.fork in jacoco.Config := true
).enablePlugins(PlayJava).disablePlugins(plugins.JUnitXmlReportPlugin).dependsOn(
proj1 % "compile->compile",
proj2 % "compile->compile",
proj3 % "compile->compile",
proj4 % "compile->compile",
).aggregate(
proj1,
proj2,
proj3,
proj4
)
lazy val proj1 = (project in file("modules/proj1")).configs(IntegrationTest).settings(commonSettings: _*).settings(
libraryDependencies ++= appDependencies
).enablePlugins(PlayJava)
fork in run := false
PlayKeys.externalizeResources := false
如您所见,在aaRoot 中,我正在尝试jacoco.includes 其他模块目标文件夹中的类文件(我尝试了其他几种方法,但没有任何效果)。所有测试用例都运行良好,但jacoco 无法涵盖任何内容。
[info] ------- Jacoco Coverage Report --------
[info]
[info] Lines: 0% (>= required 0.0%) covered, 0 of 0 missed, OK
[info] Instructions: 0% (>= required 0.0%) covered, 0 of 0 missed, OK
[info] Branches: 0% (>= required 0.0%) covered, 0 of 0 missed, OK
[info] Methods: 0% (>= required 0.0%) covered, 0 of 0 missed, OK
[info] Complexity: 0% (>= required 0.0%) covered, 0 of 0 missed, OK
[info] Class: 0% (>= required 0.0%) covered, 0 of 0 missed, OK
[info] Check /Users/RP/application/target/jacoco for detail report
很明显,jacoco.includes 没有查看我要求查看的任何课程。
我尝试了很多方法并尝试使用it-jacoco:cover,但没有任何效果。任何提示或帮助都会受到欢迎。
【问题讨论】:
标签: playframework playframework-2.0 sbt jacoco