我正在尝试使用scalamock / scalatest,我在测试期间总是出错
我的build.sbt
name := "name"
organization := "org"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.7"
scalacOptions ++= Seq("-feature", "-language:postfixOps","-language:existentials")
libraryDependencies <<= scalaVersion { scala_version =>
val sparkVersion = "1.5.1"
Seq(
"org.scalatest" %% "scalatest" % "2.2.5" % "test",
"org.scalamock" %% "scalamock-scalatest-support" % "3.2" % "test",
"junit" % "junit" % "4.11" % "test",
"org.apache.spark" %% "spark-streaming" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.apache.spark" %% "spark-core" % sparkVersion,
"com.typesafe" % "config" % "1.3.0"
)
}
我的单元测试:
@Test
class BWPMDAOTest extends FlatSpec with Matchers with MockFactory{
val sparkcontext = mock[SparkContext]
val dao = new BWPMDAO(sparkcontext)
dao.getStatsAsList() should not be null
dao.getStatsAsList() should not be empty
}
当我运行sbt test
时出现以下错误:
Error:scalac: missing or invalid dependency detected while loading class file 'MetricsSystem.class'.
Could not access term eclipse in package org,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'MetricsSystem.class' was compiled against an incompatible version of org.
我该如何解决?
谢谢
答案 0 :(得分:0)
我添加了一个码头依赖,例如对于sbt "org.eclipse.jetty" % "jetty-servlet" % "9.3.9.v20160517"
然后它起作用了。