java - While inject mock error throws from logger -


here's example code. class a class going write test case.

class {      private static log logger = logfactory.getlog(a.class);      @autowired     abdul abdul;      public object getdetails(){         return abdul.getdetails();     } }   class abdul {      public object getdetails(){          return new object();     } }   class atest{      @injectmocks     a;      @mock     private abdul abdul;      @before     public void initmocks(){         mockitoannotations.initmocks(this);     }  } 

i getting following error when @injectmocks called :-

 log4j:error setfile(null,true) call failed error throws 

when attempted mock logger using powermock got following error:

org.mockito.exceptions.misusing.nullinsteadofmockexception:  argument passed when() null! example of correct stubbing:     dothrow(new runtimeexception()).when(mock).somemethod(); also, if use @mock annotation don't miss initmocks() 

please me resolve it. in advance.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -