How to create liquibase changeset for integration tests in springboot?

You can use liquibase's context parameter. For example create changeset which will have inserts loaded from sql file and specify the context for it. Something like this:

<changeSet id="test_data_inserts" author="me" context="test">
    <sqlFile path="test_data.sql" relativeToChangelogFile="true" />
</changeSet>

and in spring boot's application.properties for test specify the property liquibase.contexts=test.


Assume production changeset placed inside resources/db/changelog/changes, and there is a db.changelog-master.yaml in /db/changelog with following config

databaseChangeLog:
  - includeAll:
      path: db/changelog/changes

Place the testing changset inside test/resources/db/changelog/testchanges and create db.changelog-master.yaml in test/resources/db/changelog with following config

databaseChangeLog:
  - includeAll:
      path: db/changelog/changes
  - includeAll:
      path: db/changelog/testchanges

The test should pick up all changeset in two paths and run