title: properties from 'application.yml' not loading for standalone application when you try to run JUnit Test against it
body: <p>I have class application which run fine when you run it as spring boot application and loads the properties from <code>src/main/resources/application.yml</code> like below</p>
  <pre><code>class abc{
  
          @Value(&quot;${spring.host}&quot;)
          private String host;
          
      private ConnectionFactory getConnection() {
      ConnectionFactory factory = new ConnectionFactory();//constructs Connection instances
      factory.setHost(host);
      return factory;
         }
       }
  </code></pre>
  <p>below is the application.yml details</p>
  <pre><code>spring.host: xx.xx.xx.1
  </code></pre>
  <p>But when you try to run junit test against above <code>class abc</code> then it doesn't upload the properties from <code>src/main/resources/application.yml</code>. Even i have also created a test file application.yml under <strong>test directory</strong>
  <code>src/test/resources/application.yml</code> with the following details</p>
  <pre><code>spring.host: xx.xx.xx.1
  </code></pre>
  <p>Below is my Junit test class details</p>
  <pre><code>@RunWith(SpringRunner.class)
  @TestPropertySource(properties = { &quot;spring.config.location=classpath:application.yml&quot; })     
  @TestPropertySource(properties = {&quot;spring.test1= xx.xx.xx.2&quot;,
      &quot;spring.test2= 1111&quot;
      })
  @ContextConfiguration(initializers = { ConfigFileApplicationContextInitializer.class })
  
  public class Testclass {
     
  InjectMocks
  private abc ab;
  
  @Value(&quot;${spring.test1}&quot;) /// here it is getting uploaded from src/main/resources/application.yml 
    private String test1;
  
  @Test
  public void testExecute() throws Exception {
  abc.getConnection();
     }
   }
  </code></pre>
  <p>i am having hard time to understand and debug why the same configuration doesn't work from JUnit for loading properties from application.yml but it works well when simply run class <code>abc</code> as your standalone application.</p>