Skip to content

Latest commit

 

History

History

embedded-db-flyway

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

embedded-db-flyway

Plugin for the embedded-db-junit that allows for Flyway migrations to be run for the embedded database before the tests are executed.

Usage instructions

Add dependency

<dependency>
    <groupId>org.zapodot</groupId>
    <artifactId>embedded-db-flyway</artifactId>
    <version>...</version>
    <scope>test</scope>
</dependency>

Set up as an initialization plugin

@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());
    }
}

Analytics