title: java.lang.IllegalStateException: Failed to load ApplicationContext-How to test main class of Spring-boot application
body: <p>I have a spring-boot application where my <code>@SpringBootApplication</code> starter class looks like a standard one and getting Caused by: </p>
  
  <blockquote>
    <p>org.springframework.beans.factory.BeanDefinitionStoreException: Failed
    to parse configuration class [com.abct.ECRRestServer];</p>
    
    <p>nested exception is java.io.FileNotFoundException: Could not open
    ServletContext resource [/application.properties]</p>
  </blockquote>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  public class ECRRestServerTest {
  
      @Test
      public void contextTest() {
  
      }
  }
  </code></pre>
  
  <p>Encountering below issue. </p>
  
  <blockquote>
    <p>2019-04-27 18:51:25.732 ERROR 15096 --- [           main]</p>
    
    <p>o.s.test.context.TestContextManager      : Caught exception while
    allowing TestExecutionListener
    [org.springframework.test.context.web.ServletTestExecutionListener@78e117e3]
    to prepare test instance [com.abct.ECRRestServerTest@16ecee1]</p>
    
    <p>java.lang.IllegalStateException: Failed to load ApplicationContext
         Caused by: org.springframework.beans.factory.BeanDefinitionStoreException:</p>
    
    <p>Failed
    to parse configuration class [com.abct.ECRRestServer]; nested
    exception is java.io.FileNotFoundException: Could not open
    ServletContext resource [/applicati</p>
    
    <p>on.properties]</p>
  </blockquote>