【发布时间】:2015-10-17 17:22:22
【问题描述】:
在我的代码中,有:
def submitContent(getDocContent: () => String, callback: Try[Boolean] => Unit): Unit = {
// ....
callback(Failure(new InflightChangeTimeoutException(pendingChange)))
}
我想在某些条件下进行测试,callback 将被一些 InflightChangeTimeoutException 调用,但我不关心异常的值是什么。
在我的 speces2 测试中,我尝试了:
val callback = mock[Try[Boolean] => Unit]
submitContent(() => "any-other", callback)
there was one(callback).apply(===(Failure(any[InflightChangeTimeoutException])))
会给我一些错误,例如:
The mock was not called as expected:
Argument(s) are different! Wanted:
function1.apply(
'Failure(com.test.InflightChangeTimeoutException)'
is not equal to
'Failure(null)'
);
不知道哪里错了。如何解决?
【问题讨论】: