title: Getting a NullPointerException when testing a Spring application
body: <p>I am new to testing with Spring Boot, and am currently trying to make a simple test run. </p>
  
  <p>The method I want to test is:</p>
  
  <pre><code>public class DigipostSpringConnector {
  
  @RequestMapping("/test")
  public String test(){
      return "Hello";
  }
  </code></pre>
  
  <p>The test class I have written so far is:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(classes = DigipostSpringConnector.class)
  @WebAppConfiguration
  
  public class DigipostSpringConnectorTest {
  
      private MockMvc mvc;
  
      @Before
      public void setup() throws Exception{
          mvc = MockMvcBuilders.standaloneSetup(new DigipostSpringConnector()).build();
      }
  
      @Test
      public void getHello() throws Exception {
          mvc.perform(MockMvcRequestBuilders.get("/test"))
                  .andExpect(status().isOk())
                  .andExpect(content().string(equalTo("Hello")));
      }
  
  }
  </code></pre>
  
  <p>However, I get a NullPointerException when I run the test, the exception appears on the following line:</p>
  
  <pre><code>mvc.perform(MockMvcRequestBuilders.get("/test"))
  </code></pre>
  
  <p>It seems like the field MockMvc mvc-field is not being initialized. </p>
  
  <p>What could be going wrong here?</p>
  
  <p>Thank you!</p>