0

我正在尝试使用 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.

我该如何解决?

谢谢

4

1 回答 1

0

我为 sbt 添加了一个 jetty 依赖项"org.eclipse.jetty" % "jetty-servlet" % "9.3.9.v20160517",然后它就起作用了。

于 2016-06-06T12:14:48.923 回答