java - Mocking a void method from the same class that is being tested -
i trying test method using mockito , powermockito, method internally calling method returns void, wanted mock method since dont care result of method. have been trying on unable find solution please me on this. i tries using powermockito searchprocedurecodecontrollerbean mock = mock(searchprocedurecodecontrollerbean.class); powermockito.donothing().when(mock).seterrormessage((string)anyobject(), mockito.anylist().toarray(), (string)anyobject(), (string)anyobject()); seterrormessage void method, signature method follows public void seterrormessage(string errorname, object[] arguments, string messagebundle, string componentid) { } you can stub method of mocked object only. tested object not mocked. power mockito can stub static methods, it's not case. if don't care method behavior leave this. it`s void baisically don't matter. if , suppress it's influence, mean real problem design class under test owns responsibility. extract method class