flyway-test-extensions

flyway-test-extension logo

Test extensions for the Flyway project

For Flyway's features, see the Flyway Db Org Page

Version 6.4.0 Released

2020-05-29 flyway-test-extensions version 6.4.0 released.

Version number 6.4.x are used to show the dependency to Flyway version 6.4.x.

See also Release Notes

Central maven repository under http://search.maven.org/#search|ga|1|flyway-test-extensions contains all project jars.

Project

This extension gives the ability to reset and/or fill the database with defined content.
With this precondition, each test provides a reproducible database start point.

How to use it

The flyway test extensions are available at Maven Central.

For a detail usage description see the UsageFlywaySpringTest usage page.
Attention:

Integration

    <dependency>
       <groupId>org.flywaydb.flyway-test-extensions</groupId>
       <artifactId>flyway-spring-test</artifactId>
       <version>6.4.0</version>
       <scope>test</scope>
    </dependency>
    @RunWith(SpringRunner.class)
    @ContextConfiguration(locations = {"/context/simple_applicationContext.xml" })
    @TestExecutionListeners({DependencyInjectionTestExecutionListener.class, 
                             FlywayTestExecutionListener.class })
    // usage as once per class
    @FlywayTest
    public class Spring4JUnitTest 

    // another TestClass

    public class Spring4JUnitTest {

    // usage as per test method
    @Test
    @FlywayTest
    public void testMethod() { 
    // usage as once per class
    @FlywayTests(value = {
    @FlywayTest(flywayName = "flyway1"),   // Flyway configuration for database 1
    @FlywayTest(flywayName = "flyway2")    // Flyway configuration for database 2
    })
    public class Spring4JUnitTest 

    // another TestClass

    public class Spring4JUnitTest {

    // usage as per test method
    @Test
    @FlywayTests(value = {
    @FlywayTest(flywayName = "flyway3"), // Flyway configuration for database 3
    @FlywayTest(flywayName = "flyway4")  // Flyway configuration for database 4
    })
    public void testMethod() { 
@ExtendWith({SpringExtension.class})
@ExtendWith({FlywayTestExtension.class})
@ContextConfiguration(locations = { "/context/simple_applicationContext.xml" })
@FlywayTest         // as class annotation
public class Junit5SpringTest ...

    @BeforeEach
    @FlywayTest(locationsForMigrate = {"loadmsqlbefore"})  // together with BeforeEach
    public void before() {
    ...

    @Test
    @FlywayTest       // as method annotation
    public void testMethodLoad() {
@ContextConfiguration(locations = {"/context/simple_applicationContext.xml"})
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class,
        FlywayTestExecutionListener.class})
@Test
@FlywayTest(locationsForMigrate = {"loadmsql"}) // execution once per class
public class MethodTest extends AbstractTestNGSpringContextTests {

    @BeforeClass
    @FlywayTest(locationsForMigrate = {"loadmsql"}) // execution once per class
    public static void beforeClass(

    @BeforeMethod
    @FlywayTest(locationsForMigrate = {"loadmsql"}) // execution before each test method
    public void beforeMethod(

    @Test
    @FlywayTest(locationsForMigrate = {"loadmsql"}) // as method annotation
    public void simpleCountWithoutAny(

Project depend on

Notes