Unit testing Liquibase changesets in modules

Hi @dkayiwa, @wyclif, @raff,

Long story short, I could do it :wink: but this requires a little change in Core. I just would like to know if I’m correct or missing something.

My specific issue is that I wanted to execute a test data set coming as a test resource of my custom module. The hurdle is here in DatabaseUpgradeTestUtil:

public void executeDataset(String path) {
  InputStream inputStream = getClass().getResourceAsStream(path);

I am under the impression that this line will only ever enable to load Core resources only, am I correct?
On my fork I have worked around this by introducing another method:

public void executeDataset(InputStream inputStream) { ...

This obviously works, but my question is: how would you recommend to change DatabaseUpgradeTestUtil so that it could also load other-than-Core resources?

Cc: @oslynn

The original method should work for both core and module resources. How does your path look like? Assuming you have /src/main/resources/liquibase.xml in your module you should pass “/liquibase.xml” as the path… (note it is an absolute path and not a reliative one).

This is not the method to run the liquibase.xml file, this is a method that allows to load test data sets in the in-memory database.

See here for example.

The actual .upgrade() method works fine though, that’s not the issue.

Yes, sorry, I meant to explain how to construct a path to any file and not liquibase.xml in particular. Does using an absolute path (starting with ‘/’) work ?

1 Like

Yes that worked, thanks @raff!