title: Spring-Boot @TestPropertySource not loading the external properties file when used with @SpringBootTest
body: <p>I am new to Spring Boot, I am having trouble in loading properties file using @TestPropertySource annotation along with @SpringBootTest , Here is my code </p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest()
  @TestPropertySource(locations="classpath:test_application.properties")
  @Sql(value = {"/user_test_script.sql"})
  @AutoConfigureTestDatabase(replace = Replace.NONE)
  public class UserServiceImpleIntegrationTest {
  
  
      @Autowired
      private UserService userService;
  
      @Autowired
      ApplicationContext applicationContext;
  
  
      @Test
      public void testGetAllGuestUsers() throws IOException {
          List&lt;User&gt; users =userService.getAllGuestUsers(0, 10);
  
          assertThat(users).isNotNull();
          assertThat(users).isNotEmpty();
          assertThat(users).are(new Condition&lt;User&gt;() {
                 public boolean matches(User user) {
                       return user.getFirstName().contains("Guest");  }
                   });
      }
  }
  </code></pre>
  
  <p>Here is my test_application.properties file content </p>
  
  <pre><code># Connection url for the database "test"
  spring.datasource.url=jdbc:mysql://localhost:3306/test_db
  spring.datasource.driverClassName=com.mysql.jdbc.Driver
  spring.datasource.username=root
  spring.datasource.password=root
  
  
  # Hibernate
  spring.jpa.hibernate.ddl-auto=create-drop
  spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
  spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
  spring.jpa.show-sql = true
  spring.jpa.properties.hibernate.format_sql=true
  spring.datasource.testWhileIdle = true
  spring.datasource.validationQuery = SELECT 1
  
  
  #LOGGING
  logging.level.org.hibernate.SQL=DEBUG
  logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE 
  logging.level.org.springframework.web=ERROR
  logging.level.org.hibernate=DEBUG
  
  spring.profiles.active=junit
  
  #TransactionManagement
  logging.level.org.springframework.transaction.interceptor=TRACE
  </code></pre>
  
  <p>My classpath:test_application.properties is located in src/test/resources location. </p>
  
  <p>When I used the same @TestPropertySource annotation with @DataJpaTest ,properties files are loading as excepted.Here is my code for the same</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @DataJpaTest
  @AutoConfigureTestDatabase(replace = Replace.NONE)
  @Sql(value = {"/item_test_script.sql" ,"/image_test_script.sql"})
  @TestPropertySource(value="classpath:test_application.properties") 
  public class ItemRepoTest {
  
  
      @Autowired
      ItemRepo itemRepo;
  
      @Test
      public void testGetAllImagesByItemId() {
          List&lt;Image&gt; images= itemRepo.getAllImagesByItemId(1l);
          assertThat(images).isNotEmpty();
          assertThat(images).size().isGreaterThanOrEqualTo(1);
  
      }
  
  }
  </code></pre>
  
  <p>The very strange thing is If I use properties attribute as </p>
  
  <blockquote>
    <p>@TestPropertySource(properties=
    {"spring.datasource.username=root","spring.datasource.password=root"})</p>
  </blockquote>
  
  <p>instead of location attribute then these values are taken to load the database.what I am missing here , Or what configuration is wrong.  </p>