NoSuchMethodError:org.scalactic.anyvals.PosInt用于集成测试执行

时间:2019-04-04 13:34:55

标签: scala intellij-idea sbt scalatest

我正在使用ScalaTest依赖项进行集成测试,当我运行集成测试时,有时它们可​​以正常工作,有时我会收到此错误:

java.lang.NoSuchMethodError: org.scalactic.anyvals.PosInt$.ensuringValid(I)I
  at org.scalatest.prop.Configuration$PropertyCheckConfiguration$.apply$default$1(Configuration.scala:44)
  at org.scalatest.prop.Configuration$class.$init$(Configuration.scala:561)
  at org.scalatest.prop.Configuration$.<init>(Configuration.scala:569)
  at org.scalatest.prop.Configuration$.<clinit>(Configuration.scala)
  at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:919)
  at org.scalatest.tools.Runner$.run(Runner.scala:855)
  at org.scalatest.tools.Runner.run(Runner.scala)
  at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:131)
  at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:28)

当我重新启动IntelliJ IDEA时,测试将正确执行。可能是什么原因?

我怀疑存在一些依赖项冲突,因为仅在重建sbt之后才会出现此错误。但是,我不确定到底是什么问题。 这是我在build.sbt中拥有的一组依赖项:

name := "TBC_DEV"

version := "0.1"

scalaVersion := "2.11.8"

Defaults.itSettings

fork := true

lazy val root = project in file(".") configs(IntegrationTest)

val funTestFilter: String => Boolean = { name =>
  name endsWith "IntegrationTest"
}

testOptions in IntegrationTest += Tests.Filter(funTestFilter)
test in IntegrationTest := (test in IntegrationTest).value
testOnly in IntegrationTest := (testOnly in IntegrationTest).evaluated

val sparkVersion = "2.4.0"
val circeVersion = "0.11.0"

dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-core" % "2.9.5"
dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.5"
dependencyOverrides += "com.fasterxml.jackson.module" % "jackson-module-scala_2.11" % "2.9.5"
resolvers += "Spark Packages Repo" at "http://dl.bintray.com/spark-packages/maven"
resolvers += "confluent" at "http://packages.confluent.io/maven/"

libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % sparkVersion,
  "org.apache.spark" %% "spark-sql" % sparkVersion,
  "org.apache.spark" %% "spark-hive" % sparkVersion,
  "org.apache.spark" %% "spark-streaming" % sparkVersion,

  "org.apache.spark" %% "spark-streaming-kafka-0-10" % sparkVersion exclude ("org.apache.kafka","kafka"),
  "org.apache.spark" %% "spark-sql-kafka-0-10" % "2.4.0",
  "org.apache.kafka" %% "kafka" % "2.1.0",

  "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % "it",
  "org.scalacheck" %% "scalacheck" % "1.14.0" % "it",

  "io.kubernetes" % "client-java" % "3.0.0" % "it",

  "org.json" % "json" % "20180813",
  "io.circe" %% "circe-core" % circeVersion,
  "io.circe" %% "circe-generic" % circeVersion,
  "io.circe" %% "circe-parser" % circeVersion,

  "org.apache.avro" % "avro" % "1.8.2",
  "org.apache.spark" %% "spark-avro" % "2.4.0",
  "io.confluent" % "kafka-avro-serializer" % "5.0.1",

  "org.apache.logging.log4j" % "log4j-core" % "2.7",
  "org.apache.logging.log4j" % "log4j-api" % "2.7",

  "io.prestosql" % "presto-jdbc" % "304" % "it, test",
  "com.facebook.presto" % "presto-jdbc" % "0.217" % "it, test",

  "com.microsoft.azure" % "azure-sqldb-spark" % "1.0.2",
  "com.microsoft.sqlserver" % "mssql-jdbc" % "7.2.0.jre8",

  "com.typesafe" % "config" % "1.3.3"
)

test in assembly := {}

assemblyMergeStrategy in assembly := {
  case PathList("org", "apache", "spark", "unused", "UnusedStubClass.class") => MergeStrategy.first
  case PathList("org", "apache", "commons", "logging", _*) => MergeStrategy.first
  case PathList("org", "apache", "commons", "beanutils", _*) => MergeStrategy.first
  case PathList("org", "apache", "commons", "collections", _*) => MergeStrategy.first
  case PathList("org", "apache", "hadoop", "yarn", _*) => MergeStrategy.first
  case PathList("org", "aopalliance", _*) => MergeStrategy.first
  case PathList("org", "objenesis", _*) => MergeStrategy.first
  case PathList("com", "sun", "jersey", _*) => MergeStrategy.first
  case PathList("org", "apache", "hadoop", "yarn", _*) => MergeStrategy.first
  case PathList("org", "slf4j", "impl", _*) => MergeStrategy.first
  case PathList("com", "codahale", "metrics", _*) => MergeStrategy.first
  case PathList("javax", "transaction", _*) => MergeStrategy.first
  case PathList("javax", "inject", _*) => MergeStrategy.first
  case PathList("javax", "xml", _*) => MergeStrategy.first
  case PathList("META-INF", "jersey-module-version") => MergeStrategy.first
  case PathList("plugin.xml") => MergeStrategy.first
  case PathList("parquet.thrift") => MergeStrategy.first
  case PathList("git.properties") => MergeStrategy.first
  case PathList("codegen", "config.fmpp") => MergeStrategy.first
  case PathList("overview.html") => MergeStrategy.discard
  case x => (assemblyMergeStrategy in assembly).value(x)
}

0 个答案:

没有答案