Skip to content

Home: flyway test extension

FlorianGWE edited this page Nov 24, 2013 · 4 revisions

Table of Contents

Test extensions for the Flyway project

For feature of Flyway see Flyway Db Org Page

Version 2.2.1 Released

2013-09-12 flyway-test-extensions version 2.2.1 released.

Version number 2.2.1 are used to show the dependency to Flyway version 2.2.1.

See also Release Notes

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

Project

This extension give the possibility to reset and/or fill the database with defined content.
With this precondition each test had reproducible database start point.

  • Annotation support FlywayTest for database unit testing. Use Flyway feature.
    • clean - execution of flyway task clean
    • init - execution of flyway task init
    • migrate - execution of flyway task migrate
  • Annotation can be used at
    • each test class (once per test case)
    • each test method
  • Samples projects to use annotation inside a unit testing environment
  • Additional project supports a DBUnit annotation use together with FlywayTest DBUnitSupport. A usage example you will find at UsageFlywayDBUnitTest.

How to use it

The flyway test extension are available at Maven Central.

For a detail usage description see the UsageFlywaySpringTest usage page.

  • add dependency to flyway-spring-test to your Mavan pom file
    <dependency>
       <groupId>com.googlecode.flyway-test-extensions</groupid>
       <artifactId>flyway-spring-test</artifactid>
       <version>2.2.1</version>
       <scope>test</scope>
    </dependency>
  • Extend your test class with the Spring test runner annotation.
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = {"/context/simple_applicationContext.xml" })
    @TestExecutionListeners({DependencyInjectionTestExecutionListener.class, FlywayTestExecutionListener.class })





  • add the @FlywayTest annotation on each class or method were you need a clean database
    @FlywayTest
    public class Spring3JUnitTest 

Project depend on

Notes

  • The project depends on flyway version 2.2.1
  • The project will be supported until the extension will be integrated into the flyway project.
  • The project depends on Spring version 3.1
    • All features works with Spring version 3.x
    • It works also with Spring version 2.5.6, but you can not use all features. A example project show how to use it with Spring 2.5.6
  • At the moment the code is tested with database H2 and Oracle.
    Only the DBunit part contains database specific code.