キャストされた値を渡してオーバーロードされたメソッドをモックしようとすると、次のエラーが発生します。
たとえば、嘲笑するために
ABCClass.logWarn(Logger log,String , String description, Throwable e);
私がやっている
`ABCClass.logWarn(null,WarningString, description, (Throwable)null);
...\\ The rest of the methods are standard...
verify(event).setStatus((Throwable)null);//**Line 76**
しかし、テストケースを実行すると、次のエラーが発生します
ABCClassTest.testLogWarn:76
Wanted but not invoked:
MockEvent.setStatus(null);
-> at com.path.ABCClassTest.testLogWarn(ABCClassTest.java:76)
However, there were other interactions with this mock:.....
setStatus(null)
を具体的に呼び出した後でも、 が呼び出されること
が期待されるのはなぜsetStatus((Throwable)null);
ですか?
追加の詳細
logWarn の定義
private static void logWarn(String eventType, String eventName, String errMsg, Throwable e) {
AnEvent event = AnEventFactory.create(eventType);
event.setName(eventName);
if(e!=null)
event.setStatus(e);//so this is never called if the throwable is null.
//How do I modify the verify behavior?
/*
Bleh */
event.completed();
}