0
在我的代碼,有:如何驗證傳遞給模擬函數的異常的類型?
def submitContent(getDocContent:() => String, callback: Try[Boolean] => Unit): Unit = {
// ....
callback(Failure(new InflightChangeTimeoutException(pendingChange)))
}
我想測試在某些情況下,callback
將與一些InflightChangeTimeoutException
一個Failure
被調用,但我不」關心什麼異常的價值。
在我speces2測試,我tryied:
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)'
);
不知道是哪裏不對。如何解決它?
非常感謝你所有的時間 – Freewind