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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -