sbt-jacoco
sbt-jacoco copied to clipboard
ClassCastException when using forked mode tests
Example project: https://github.com/retronym/jacoco4sbt-demo/tree/bug/fork
> jacoco:cover
Nov 27, 2013 9:54:56 AM Test$ $jacocoInit
INFO: 2d8b62e0
[error] Test CoverageTest.main failed: java.lang.ExceptionInInitializerError: null
[error] at CoverageTest.main(CoverageTest.scala:4)
[error] ...
[error] Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to [Z
[error] at Test$.$jacocoInit(Source.scala)
[error] at Test$.<clinit>(Source.scala)
[error] ... 36 more
I can verify that I also have this issue. I'm using:
testGrouping in jacoco.Config := {
val original: Seq[Tests.Group] = (testGrouping in jacoco.Config).value
original.map { group =>
val forkOptions = ForkOptions(
bootJars = Nil,
javaHome = javaHome.value,
connectInput = connectInput.value,
outputStrategy = outputStrategy.value,
runJVMOptions = javaOptions.value,
workingDirectory = Some(new File(System.getProperty("user.dir"))),
envVars = envVars.value
)
group.copy(runPolicy = Tests.SubProcess(forkOptions))
}
}
Which was suggested as a fix for multiproject builds here: https://github.com/playframework/playframework/issues/1834
It has been stated here that jacoco4sbt will not work when forking. It seems that's still an issue, and I can confirm I have the same error as above.
Forked tests should work as of version 2.1.4 of the plugin. At least my own tests say so. - Could you please verify?
Same error on 2.1.4 :( Forked or not forked.
A sample for a working project configuration with forked tests can be found in the test resources here: https://github.com/sbt/jacoco4sbt/tree/master/src/test/resources/jacocoTestForked - maybe this helps? - Otherwise, could someone with the problem please post a small example where the forked tests fail?
I recently observed this when trying to use sbt-cucumber with jacoco. See link here: https://github.com/sbt/sbt-cucumber/issues/1