I'm using EasyMock 3+.
I'm testing a method e.g. processMessage()
, which (would) meet my tests, but at the very end of the method this method also calls another method dispatchMessage(String msg)
of the same class. That latter method takes on a @EJB injected object, which I really don't care about in this test. Of course - this object result in a NullPointerException.
How can I mock with Easymock this method to simply ignore it's code and return void. i.e.
void dispatchMessage(String msg){
return;
}
thanks
There is no need to invoke
replay
orverify
. I did it like this. Added the@BeforeClass
annotation.Then created an EasyMock builder instance and added the method I'm NOT interested in. Now, thi
Following by this code, which invokes the method under test (original objective)...
Of course, if I omit the partial mock, it throws a null pointer exception as initially described. Now, it doesn't do so anymore. All good.