title: When spring looks to test/resources?
body: <p>Working on unit tests in Spring boot application and came across an issue: I put </p>
  
  <pre><code>application.properties 
  data.sql
  </code></pre>
  
  <p>files under <code>src/main/resources</code> </p>
  
  <p>and</p>
  
  <pre><code>application-test.properties
  data-test.sql
  </code></pre>
  
  <p>files under <code>src/test/resources</code> </p>
  
  <p>But realized when @SpringBootTest starting it anyway uses data.sql from  <code>src/main/resources</code>
  Browsing internet ( and this site particularly) I found the solution: </p>
  
  <ol>
  <li>use <code>@ActiveProfiles("test")</code> with @SpringBootTest</li>
  <li><code>spring.datasource.platform=test</code> <code>in application-test.properties</code></li>
  </ol>
  
  <p>But even after that I realized <code>data.sql</code> is still working. Actually I see the right way: use profiles for everything: test, dev, etc. And put <code>profile=dev</code> in run configuration and rename <code>data.sql</code> to <code>data-dev.sql</code></p>
  
  <p>So may be may be it worth to go further and manually define everything: 3.<code>@TestPropertySourcelocations="classpath:test.properties"</code></p>
  
  <p>OR</p>
  
  <pre><code>@TestPropertySource(properties = {
                  "spring.jpa.hibernate.ddl-auto=validate",
                  "liquibase.enabled=false"
          }
  )
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>@Sql({"/data-test.sql"})
  </code></pre>
  
  <p>So my question is: is putting files under <code>src/test/resources</code> <strong>gives nothing</strong> in prior of <code>src/main/resources</code>? And anyway need to care about profiles ( which seems a silver bullet in this context).
  Why spring doesn't understand that it should use resources from <code>src/test/resources</code> while testing? </p>
  
  <p>(from my point now it seems completely misleading such secularization to <code>src/test/resources</code> and <code>src/main/resources</code> which seems looks promising but gives nothing... what I'd like to see: put file at <code>main</code> and expect it in main app, put the file with the same name under <code>test</code> and expect it uses while uni testing only)</p>