Spring Boot: How to setup test data with liquibase in unit test
<p>I'm trying to setup the database schema and some test data with liquibase for some tests. Each test has a separate changelog which setup the schema and some specific data for the test.</p>

<p>In order to make my tests working, I need to drop the schema before each test and fill it with new test data. However, it seems that this is not working because some tests are failing because the old test data is still available. I think something with my configuration is not correct. How can I force liquibase to drop the schema before each test?</p>

<p>My tests look as following:</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyTestConfig.class)
@TestPropertySource(properties = "liquibase.change-log=classpath:changelog/schema-with-testdata.xml")
public class MyRepositoryTest {
</code></pre>

<p>The config for the tests looks as follows:</p>

<pre><code>@SpringApplicationConfiguration
@Configuration
@EnableAutoConfiguration
@ComponentScan("com.mypackage")
@EntityScan(basePackages = { "com.mypackage.domain" })
@EnableJpaRepositories(basePackages = { "com.mypackage.domain", "com.mypackage.infra.persistence" })
public class MyTestConfig {
</code></pre>

<p>And the application.properties under src/main/test/resources is </p>

<pre><code>liquibase.drop-first=true
spring.jpa.hibernate.ddl-auto=none
</code></pre>