我正在编写一个模拟对象,如下所示:
import org.specs2.mock._
import com...MonetaryValue
import com...Voucher
import org.mockito.internal.matchers._
/**
* The fake voucher used as a mock object to test other components
*/
case class VoucherMock() extends Mockito {
val voucher: Voucher = mock[Voucher]
//stubbing
voucher.aMethod(any(classOf[MonetaryValue])) answers {arg => //some value to be return based on arg}
def verify() = {
//verify something here
}
}
存根步骤引发异常:
...type mismatch;
[error] found : Class[com...MonetaryValue](classOf[com...MonetaryValue])
[error] required: scala.reflect.ClassTag[?]
[error] voucher.aMethod(any(classOf[MonetaryValue])) answers {arg => //some value to be return based on arg}
我想从参数中获取值并根据此参数返回一个值,如下所示:http ://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#11
我试过了isA, anyObject...
这种情况下正确的参数匹配器是什么?非常感谢。