The following code:
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))
}
}
Gives me a runtime error org.scalamock.MockFunction1 cannot be cast to org.scalamock.StubFunction1
. My project dependencies are:
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"
)
Any ideas? Thanks!
mock
is write-only. am i missing something as to why this is? – Korean