title: Junit mockito when(..).thenReturn() NullPointerException
body: <p>I am writing the unit test to Class_b and getting Null pointers exception due to when().thenReturn(). Found it through the debugger. Any help will be appreciable.</p>
  <pre><code>@Component
  Class_b{
      
      @Autowired
      private Class_a class_a;
  
      fun_b(par){
          result = class_a.fun_a()
          // uses result and returns
      }
  }
  
  @Component
  Class_a{
      
      fun_a(par){
          // Some logic
          returns;
      }
  }
  
  @Runner
  Class_b_Test{
  
     @InjectMocks
     private Class_b class_b;
  
     @Mock
     private Class_a class_a;
  
     @Test
     fun_testing(){
          when(class_a.fun_a(par)).thenReturn(something)
          result = class_b.fun_b(par)
           // Does validation
     }
  }
  </code></pre>