seeker
seeker

Reputation: 6991

Passing a null object to mockito

First off I'm very new to mockito. I happened to overload a couple of methods in a legacy code base, that I was working on. However, as a result I had to change the test classes in order to make sure that the earlier test methods still called their original(intended) methods, one of the methods was passing in a null object earlier and as a result of the overloading, I had to do a cast ie. Throwable(null) in the caller, and make a corresponding change in the verify event. So something like

ABCClass.logWarn(null,WarningString, description, (Throwable)null);
verify(event).setStatus(IsNull(Throwable.class));// this throws a compiler error asking me to create a method IsNull<Throwable>

Any thoughts on how I should fix this?

Upvotes: 1

Views: 703

Answers (1)

Kevin Welker
Kevin Welker

Reputation: 7937

I would think this would work:

verify(event).setStatus((Throwable)null);

Upvotes: 2

Related Questions