Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run code coverage for integration tests in Play 2.4.2 project #59

Open
kangastalo opened this issue Oct 16, 2015 · 10 comments
Open

Comments

@kangastalo
Copy link

We are upgrading from Play 2.1.4 to Play 2.4.2 and we would like to start using jacoco code coverage for integration tests. I have added latest jacoco plugin to plugins.sbt (addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")) and then defined itJacoco in build.scala (itJacoco.settings) as instructed in https://github.com/sbt/jacoco4sbt/wiki.

Now as I try to compile my project, I get these errors below. If I remove the itJacoco setting from build.scala, then my project compiles ok. Jacoco for unit tests is working ok, just this itJacoco is giving me a slight headache. Can you please help?

Stack trace below:

References to undefined settings:

my_project/it:fullClasspath from my_project/it-jacoco:fullClasspath ((de.johoop.jacoco4sbt.JacocoPlugin.SharedSettings) JacocoPlugin.scala:84)

my_project/it:definedTests from my_project/it-jacoco:definedTests ((de.johoop.jacoco4sbt.JacocoPlugin.SharedSettings) JacocoPlugin.scala:91)

my_project/it:definedTestNames from my_project/it-jacoco:definedTestNames ((de.johoop.jacoco4sbt.JacocoPlugin.SharedSettings) JacocoPlugin.scala:92)

at sbt.Init$class.Uninitialized(Settings.scala:265)
at sbt.Def$.Uninitialized(Def.scala:10)
at sbt.Init$class.delegate(Settings.scala:191)
at sbt.Def$.delegate(Def.scala:10)
at sbt.Init$class.compiled(Settings.scala:138)
at sbt.Def$.compiled(Def.scala:10)
at sbt.Init$class.make(Settings.scala:144)
at sbt.Def$.make(Def.scala:10)
at sbt.Load$.apply(Load.scala:135)
at sbt.Load$.defaultLoad(Load.scala:36)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:481)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:475)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:475)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:58)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:58)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Command$.process(Command.scala:92)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:98)
at sbt.MainLoop$.run(MainLoop.scala:91)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
at sbt.MainLoop$.runLogged(MainLoop.scala:24)
at sbt.StandardMain$.runManaged(Main.scala:53)
at sbt.xMain.run(Main.scala:28)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[error] References to undefined settings:
[error]
[error]   my_project/it:fullClasspath from my_project/it-jacoco:fullClasspath ((de.johoop.jacoco4sbt.JacocoPlugin.SharedSettings) JacocoPlugin.scala:84)
[error]
[error]   my_project/it:definedTests from my_project/it-jacoco:definedTests ((de.johoop.jacoco4sbt.JacocoPlugin.SharedSettings) JacocoPlugin.scala:91)
[error]
[error]   my_project/it:definedTestNames from my_project/it-jacoco:definedTestNames ((de.johoop.jacoco4sbt.JacocoPlugin.SharedSettings) JacocoPlugin.scala:92)
[error]  
@anildes
Copy link

anildes commented Feb 14, 2016

Is there a solution I get the same issues

@maxkremer
Copy link

same here too

@hsupunw
Copy link

hsupunw commented May 13, 2016

same here

@gomes-rocket
Copy link

Currently happening with plugin version 2.2.0

@qyf404
Copy link

qyf404 commented Jul 15, 2017

same here too

@gsaad
Copy link

gsaad commented Jul 19, 2017

same here too with jacoco4sbt plugin version 2.3.0 and 2.1.6

@UnknownNPC
Copy link

UnknownNPC commented Sep 8, 2017

Looks like play project requires additional IntegrationTest configuration:

  1. lazy val root = (project in file(".")).configs(IntegrationTest)
  2. Then, set next settings:
Defaults.itSettings ++ Seq(
   unmanagedSourceDirectories in IntegrationTest <+= baseDirectory(_ / "tests" / "shared"),
   sourceDirectories          in IntegrationTest <+= baseDirectory(_ / "tests" / "integration"),
   javaSource                 in IntegrationTest <<= baseDirectory(_ / "tests" / "integration"),
   resourceDirectory          in IntegrationTest <<= baseDirectory(_ / "tests" / "resources"),
   resourceDirectories        in IntegrationTest <+= baseDirectory(_ / "tests" / "resources")
) ++ jacoco.settings ++ itJacoco.settings

In general, there's no need to use itJacoco.settings in play 2, jacoco.settings should be enough.
Using jacoco.settings only, you are able to generate (jacoco:cover) and aggregate (jacoco:aggregateReport) report (reports => when multi modules => add.aggregate(project1, project2)) without problems.

@karthikkbaalaji
Copy link

@UnknownNPC I tried using your method, I am getting the following error

[error] [/xxx/build.sbt]:125: illegal start of simple expression
[error] [/xxx/build.sbt]:129: ')' expected but eof found.

@UnknownNPC
Copy link

@karthikkbaalaji ah, true. Try to remove comma char:
replace resourceDirectories in IntegrationTest <+= baseDirectory(_ / "tests" / "resources"),
with this resourceDirectories in IntegrationTest <+= baseDirectory(_ / "tests" / "resources")

@karthikkbaalaji
Copy link

Cool it worked, @UnknownNPC

I have following setup:
test/UT
test/IT

configuring this I can run it tests using itJacoco:cover
However, when I do jacoco:cover it runs both UT and IT

Is there a way to prevent jacoco:cover to not run IT Tests?

(Apologize if it's hijacking this thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants