我有一个返回 Either[Exception, String] 的方法
class A {
def validate(a: Any) = {
case a: String => Left(...some.. exception)
case a: Any => Right(a)
}
}
class B(a: A) {
def callValidate(any: Any) = {
a.validate(any)
}
}
现在我为 B 类编写测试并且我存根方法验证
class BTest {
val param: Any = "22"
val a = mock[A]
(a.validate _).expects(param).returning(....someValue...) // . this value should be Right(....) of either function.
}
是否有可能以这种方式存根以返回Either
函数的 Right(.....) ?