Skip to Content
Former Member
Feb 01, 2018 at 09:36 AM

How to mock void private method with argument as Object?


Hello Expert I have below scenario

In public method I have 2 void private method .

In first method I have argument as String In second method I have argument as Object. I JUNIT I call this public method and want to bypass both private method .

I can able to bypass first private method i.e. argument as String By using doNothing().when(demoPrivate, method(DemoPrivate.class, "getFirstNameMethod")).withArguments(fname);

But I cant able to bypass second method i.e. argument as Object. doNothing().when(demoPrivate, method(DemoPrivate.class, "demoPrivateMethod")).withArguments(demoPrivate1);

Please help me on the above issue Regards Ruturaj