以下代码:
import org.scalamock.scalatest.MockFactory
import org.scalatest.FlatSpec
trait SomeTrait {
def getLongByInt(int: Int): Long
}
class TestScalaMock extends FlatSpec with MockFactory {
"Scala Mock" should "mock my trait" in {
val someTrait = mock[SomeTrait]
(someTrait.getLongByInt _) when (1) returns 2L
assert(2L == someTrait.getLongByInt(1))
}
}
给我一个运行时错误org.scalamock.MockFunction1 cannot be cast to org.scalamock.StubFunction1
。我的项目依赖项是:
scalaVersion := "2.11.0"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.7",
"com.typesafe.akka" %% "akka-testkit" % "2.3.7",
"org.scalatest" % "scalatest_2.11" % "2.2.1" % "test",
"org.scalamock" %% "scalamock-scalatest-support" % "3.2" % "test"
)
有任何想法吗?谢谢!