Created
February 27, 2014 15:03
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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