Plugin for the embedded-db-junit that allows for Flyway migrations to be run for the embedded database before the tests are executed.
<dependency>
<groupId>org.zapodot</groupId>
<artifactId>embedded-db-flyway</artifactId>
<version>...</version>
<scope>test</scope>
</dependency>
@Rule
public final EmbeddedDatabaseRule embeddedDatabaseRule = EmbeddedDatabaseRule.builder()
.initializedByPlugin(
new FlywayInitializer.Builder()
.withLocations("classpath:migrations/")
.build())
.build();
@Test
public void checkMigrationsHasRun() throws Exception {
try (final Connection connection = embeddedDatabaseRule.getConnection();
final Statement statement = connection.createStatement();
final ResultSet resultSet = statement.executeQuery("SELECT * FROM USER")) {
assertTrue(resultSet.next());
}
}