java - How to mock a class in another class junit mockito -


following 2 classes defined as:

class1{    public method1     {         class2.getinstance().method2();     } }  class2{    public static getinstance() { .... }     public method2() { .... }     public class3 obj = new class3(); } 

i need write junit test method1 of class1. need know how can mock getinstance() , method2() of class2.

also, please tell me how can mock object of class3.

if find hard write test class, should redesign class better testability, that's reason tdd called test driven design. should never difficult write test simple class.

however,


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -