title: Initialising a database before Spring Boot test
body: <p>I'm using JUnit to test my application and everything works fine as long as the database has been initialised before the testing (using <code>gradle bootRun</code> to run as a web-app). However, if the database is empty, the application does not seem to initialise any models or entities before testing. Is there a way I'm supposed to do this? I made an assumption that the <code>ApplicationRunner</code> class will be ran before the test and initalise the entities. Is there a way to do this or am I using the wrong approach?</p>
  
  <p>This is how my <code>application.properties</code> file is looking like:</p>
  
  <pre><code>server.port=8090
  server.ssl.key-store=classpath:keystore.jks
  server.ssl.key-store-password=123456
  server.ssl.key-password 123456
  spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
  spring.jpa.hibernate.ddl-auto=create
  spring.jpa.hibernate.naming-strategy:org.hibernate.cfg.ImprovedNamingStrategy
  application.logger.org.springframework=INFO
  </code></pre>
  
  <p>My database is stored in <code>/src/main/java/application/persistence/DbConfig.java</code> using a <code>DriverManagerDataSource</code> connection. And I have setup <code>ApplicationRunner</code> to run add a few rows to the db upon starting.</p>
  
  <p>edit:</p>
  
  <p>I should also add that these are the annotations I'm using on the JUnit test file:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @WebAppConfiguration
  @ContextConfiguration(classes={
      AdeyTrackApplication.class, 
      SecurityConfig.class, 
      WebConfig.class,
      AuthorizationController.class
      })
  </code></pre>