我有一个SBT(Play Framework)多项目应用程序设置,如下所示。所有的子模块都在modules
之下,但所有覆盖所有子模块的测试用例都在“root”项目中。SBT + JaCoCo未涵盖来自不同项目的所有“jacoco.includes”类
|-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
以及但没有任何工作。任何提示或帮助将appriciated。