-
Notifications
You must be signed in to change notification settings - Fork 35
Home: flyway test extension
FlorianGWE edited this page Nov 24, 2013
·
4 revisions
For feature of Flyway see Flyway Db Org Page
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.
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
- Spring 3.x sample (see UsageFlywaySpringTest)
- Spring 2.5.6 (see UsageFlywaySpringTest256)
- Additional project supports a DBUnit annotation use together with FlywayTest DBUnitSupport. A usage example you will find at UsageFlywayDBUnitTest.
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
- Flyway (2.2.1)
- Spring Framework test, context, jdbc (3.1 or 2.5.6)
- 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.