Spring Download: How to set up test data with Liquibase in unit test

I am trying to set up a database schema and some test data using Liquibase for some tests. Each test has a separate change log that sets up a schema and some specific data for the test.

For my tests to work, I need to drop the circuit before each test and populate it with new test data. However, this does not seem to work because some tests do not work, because the old test data is still available. I think something with my configuration is wrong. How can I get Liquibase to abandon the circuit before each test?

My tests are as follows:

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

The configuration for the tests is as follows:

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

And application.properties in src / main / test / resources

liquibase.drop-first=true
spring.jpa.hibernate.ddl-auto=none
+4
1

, . liquidibase.default-schema = schemaNameToCreate

, .

0

All Articles