title: Testing using spring boot throws null pointer exception
body: <p>I am new to spring boot and i am trying to test a very simple class. But when i run the <code>testMe()</code> below I get exception below</p>
  
  <pre><code>java.lang.NullPointerException
      at MyTest.testMe(MyTest.java:25)
      at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
      at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
  </code></pre>
  
  <p>My understanding is when the context is loaded all the beans are initialized and object <code>HelloWorld</code> is created and are autowired in <code>MyTest</code> call. But <code>helloWorld</code> object is <code>null</code> at line  <code>helloWorld.printHelloWorld();</code></p>
  
  <p>I need assistance here to understand what is missing.</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  @SpringBootTest(classes = {AppConfigTest.class})
  public class MyTest {
  
      @Mock
      @Autowired
      private Message myMessage;
  
      @Autowired
      private HelloWorld helloWorld;
  
      @Test
      public void testMe(){
         helloWorld.printHelloWorld();
      }
  }
  
  
  @Configuration
  public class AppConfigTest {
  
     @Bean
      public HelloWorld helloWorld() {
          return new HelloWorldImpl();
      }
  
      @Bean
      public Message getMessage(){
          return new Message("Hello");
      }
  }
  
  public interface HelloWorld {
      void printHelloWorld();
  }
  
  public class HelloWorldImpl implements HelloWorld {
  
      @Autowired
      Message myMessage;
  
      @Override
      public void printHelloWorld() {
          System.out.println("Hello : " + myMessage.msg);
      }
  
  }
  
  public class Message {
  
      String msg;
  
      Message(String message){
          this.msg = message;
      }
  }
  </code></pre>