我有一個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。