Skip to content

Instantly share code, notes, and snippets.

@mtgto
Created February 27, 2014 15:03
Show Gist options
  • Save mtgto/9251779 to your computer and use it in GitHub Desktop.
Save mtgto/9251779 to your computer and use it in GitHub Desktop.
Specs2's mockito cannot mock the class which have the function returns AnyVal, but this example can be passes.
import org.specs2.mutable._
import org.specs2.mock._
trait Dummy extends Any
case class V(s: String) extends AnyVal with Dummy
class A {
def f: Dummy = new V("Hello")
}
class Sample extends Specification with Mockito {
"Mockito" should {
"mock A" in {
val a = mock[A]
a.f returns new V("hoge")
a.f match {
case V("hoge") => success
case _ => failure
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment