title: Trying to run tests on Spring Boot test properties configuration
body: <p>I have Spring Boot application that normally runs on Postgres DB, however I'd like to test some features on an embedded H2 DB.
  I have tried annotating my test classes with <code>@TestPropertySource</code>and I have tried creating test and dev profiles (separate application.properties files) but none of these seem to be working. </p>
  
  <p>This is my application-test.properties</p>
  
  <pre><code>server.port=8080
  
  spring.resources.add-mappings=true
  spring.datasource.driverClassName=org.h2.Driver
  spring.datasource.url=jdbc:h2:mem:testdb;
  spring.h2.console.enabled=true
  spring.h2.console.path=/h2
  spring.datasource.username=sa
  spring.datasource.password=
  spring.jpa.hibernate.ddl-auto=create
  spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
  spring.jpa.properties.hibernate.default_schema=public
  </code></pre>
  
  <p>which is accompanied by my test data.sql script :</p>
  
  <pre><code>insert into people(first_name, last_name, id) values('John', 'Johnson', 8);
  insert into vehicles(name, make) values ('Mustang', 'Ford');
  </code></pre>
  
  <p>However even though I annotate my test class like this :</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest(classes = Main.class)
  @TestPropertySource(locations = {"classpath:application-test.properties"})
  </code></pre>
  
  <p>It still tries to run the app with the regular Postgres DB  and it is using the Postgres DB data.sql rather than the one specified above. If I switch the regular data.sql with the test one I get an error like this :</p>
  
  <pre><code>Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
  </code></pre>
  
  <p>Are there any other ways to do this? None of the solutions I could find worked for me.</p>