Question: How can I execute certain range of change-units in integration tests ?
Example of the problem: I have three change-units: X
,Y
,Z
(with order
set to: 1
, 2
, 3
). I have integration tests T1
for X
, Y
and T2
for Z
. How can I execute only migrations X
and Y
in test T1
(and "skip" Z
) ?
My solution: I see only two ways.
Assume that each test would have its own runner (like we have in MongockIntegrationTestBase#mongockBeforeEach
):
Each migration file (or a group of files) should be put in one package. And the runner would have
addMigrationScanPackage
specified (to narrow down test to only those migrations that are found in that package). In this case we would have packageP1
with migrationsX
andY
and packageP2
withZ
, so it would be:runnerBuilder.addMigrationScanPackage("P1"); return runnerBuilder.buildRunner();
Instead of the package, we would use
ChangeUnit#systemVersion
and execute runner with properties:SystemVersionable#setStartSystemVersion
andSystemVersionable#setEndSystemVersion
. In this case we would havesystemVersion
inX
,Y
,Z
set to1
,2
,3
and before running the testT1
we would have:runnerBuilder.setStartSystemVersion("1"); runnerBuilder.setEndSystemVersion("2"); return runnerBuilder.buildRunner();
Both solutions are not satisfactory for me.
- The first one looks weird to create a separate package per migration file
- The second one is slightly better, but:
SystemVersion
is not intended for that purpose- Ordering
ChangeUnit#order
would have to go in parallel withChangeUnit#systemVersion
, and that's not a good approach
Is there any other way I can solve that problem ?