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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -