次のコード:
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"
)
何か案は?ありがとう!