I have the following configuration:
├── src
│ ├── main
...
│ │ └── resources
│ │ ├── db
│ │ │ └── changelog
│ │ │ ├── changes
│ │ │ │ ├── db.changelog-1.0.insert-data.xml
│ │ │ │ └── db.changelog-1.0.xml
│ │ │ ├── db.changelog-master.xml
│ │ ├── env-profiles
│ │ │ └── application.yml
...
│ └── test
...
│ └── resources
│ ├── db
│ │ └── changelog
│ │ ├── changes
│ │ │ ├── db.changelog-1.0.insert-data.xml
│ │ │ └── db.changelog-1.0.xml
│ │ ├── db.changelog-master.xml
│ └── env-profiles
│ └── application.yml
Both application.yml
in main
and test
directories contain the same Liquibase settings:
spring:
...
liquibase:
enabled: true
change-log: classpath:db.changelog-master.xml
And this is the db.changelog-master.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<include file="db.changelog-1.0.xml" />
<include file="db.changelog-1.0.insert-data.xml" />
</databaseChangeLog>
The difference between the changelog files in main
and test
directories is around the seed data for tests.
When I run my integration tests with @SpringBootTest
I can see that the application.yml from test
is being picked up, but Liquibase executes the changsets from the main
dir rather than from test
.
How to configure Spring Boot or Liquibase to make it pick the changeset from test
directory when running tests in my current setup?