title: Mocking Autowire in a class
body: <p>I have an XYZ class which is autowired in ABC and in class MyClass I have a method name doSomething() inside that method I do ABC abc = new ABC(); Then I call abc.someMethod();</p>
  <p>Please see code sample below :</p>
  <p>Class ABC</p>
  <pre><code>public class ABC {
  
    @Autowire
    private XYZ xyz;
  
    public void someMethod()
    {
     //Some stuff
     xyz.someFunc();
  
    }
  }
  </code></pre>
  <p>Class MyCLass</p>
  <pre><code>public class MyCLass {
  
    public void doSomething() {
      ABC abc = new ABC();
      abc.someMethod();
    }
  }
  </code></pre>
  <p>Need unit test doSomething() but I NPE as XYZ is null in ABC. How can I mock @Autowire in this case.</p>