Executed NoClassDefFoundError tests in SBT with plugin with plugins

I have an SBT project with a structure like here: https://orrsella.com/2014/09/24/integration-and-end-to-end-test-configurations-in-sbt-for-scala-java-projects/ ... It includes the standard main and test directories and additionally it and e2e . There is also a " test-all" task that runs all tests. Everything works correctly unless I run e2e or test-all along with the coverage plugin. I get: java.lang.NoClassDefFoundError: scoverage / Invoker $

Using show this: dependencyClasspath and show e2e: dependencyClasspath , I can see that there is no plugin pool with extension in e2e class . Any idea what is wrong and how to solve it?

Build.sbt

import org.scalatra.sbt._
import sbt.Keys._
import sbt._

object MaAppBuild extends Build {
  val Organization = "com.my-org"
  val Name = "My App"
  val Version = "0.1.0-SNAPSHOT"
  val ScalaVersion = "2.11.6"
  val AkkaVersion = "2.3.4"

  val ScalatraVersion = "2.3.0"
  lazy val project = Project(
    "My-App",
    file("."),
    configurations = Configurations.default ++ Testing.configs,
    settings = Defaults.coreDefaultSettings ++ ScalatraPlugin.scalatraSettings ++ Testing.settings ++ Seq(
      organization := Organization,
      name := Name,
      version := Version,
      scalaVersion := ScalaVersion,
      resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
      resolvers += "Akka Repo" at "http://repo.akka.io/repository",
      libraryDependencies ++= Seq(
        "com.typesafe.akka" %% "akka-actor" % AkkaVersion,
        "com.typesafe.akka" % "akka-testkit_2.11" % AkkaVersion % "test;it;e2e",
        "net.databinder.dispatch" %% "dispatch-core" % "0.11.1",
        "org.scalatra" %% "scalatra" % ScalatraVersion,
        "com.typesafe.akka" %% "akka-testkit" % AkkaVersion % "test;it;e2e",
        "org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test;it;e2e",
        "com.github.tomakehurst" % "wiremock" % "1.55" % "test;it;e2e",
        "ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
        "org.scalatra" %% "scalatra-json" % "2.4.0.RC1",
        "org.json4s" %% "json4s-jackson" % "3.2.11",
        "com.typesafe" % "config" % "1.2.1",
        "org.json4s" %% "json4s-native" % "3.2.11",
        "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
        "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts Artifact("javax.servlet", "jar", "jar")
      )
    )
  )
}

      

Integration configuration and e2e:

import sbt.Keys._
import sbt._

object Testing {
  val IntegrationTest = config("it").extend(Runtime)

  val EndToEndTest = config("e2e").extend(Runtime)

  val configs = Seq(IntegrationTest, EndToEndTest)

  lazy val testAll = TaskKey[Unit]("test-all")

  private lazy val itSettings =
    inConfig(IntegrationTest)(Defaults.testSettings) ++
      Seq(
        fork in IntegrationTest := false,
        parallelExecution in IntegrationTest := false,
        scalaSource in IntegrationTest := baseDirectory.value / "src/it/scala",
        resourceDirectory in IntegrationTest := baseDirectory.value / "src/test/resources")

  private lazy val e2eSettings =
    inConfig(EndToEndTest)(Defaults.testSettings) ++
      Seq(
        fork in EndToEndTest := false,
        parallelExecution in EndToEndTest := false,
        scalaSource in EndToEndTest := baseDirectory.value / "src/e2e/scala",
        resourceDirectory in EndToEndTest := baseDirectory.value / "src/test/resources")


  lazy val settings = e2eSettings ++ itSettings ++ Seq(
    testAll <<= (test in EndToEndTest) dependsOn (test in IntegrationTest) dependsOn(test in Test)
  )
}

      

java.lang.NoClassDefFoundError: scoverage / Invoker $

addSbtPlugin("com.mojolly.scalate" % "xsbt-scalate-generator" % "0.5.0")

addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.5")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.1.0")

      

+3


source to share


1 answer


You seem to need to add a parameter to your sbt project:

works for me, "org.scoverage" % "sbt-scoverage" % "1.5.0"

coverageEnabled in Test := true

      



and I found that <1.4.0

there was a different solution for the version :

coverageEnabled.in(ThisBuild ,Test, test) := true

      

+1


source







All Articles