flyway / flyway-test-extensions

Apache License 2.0
129 stars 35 forks source link

flyway-dbunit-test or flyway-spring-test ? #20

Closed Ivan-Masli-GDP closed 9 years ago

Ivan-Masli-GDP commented 9 years ago

If I use Springtestdbunit (https://github.com/springtestdbunit/spring-test-dbunit) on my Unit tests, should I use flyway-dbunit-test or flyway-spring-test ?

FlorianGWE commented 9 years ago

I can not give you a general answer. It depends really on your project set up.

May be I can give you a hint for your use case.

  1. flyway-spring-test you should use if your project setup use Flyway to setup your database and in your test cases you need to reset your database to defined initial state. In this case you should use annotation @FlywayTest. So Flyway is your database master.
  2. flyway-dbunit-test is a add on for flyway-spring-test with that you can save table content or the whole database after a test run or load specific test data in your database. It does not add any support for database test validation as dbunit have. it is a load or export utility.

spring-test-dbunit have a different approach. It give you the whole DbUnit functionality support to compare and validate the database result after a test run. With this you can load complete a previous saved database, but this fit not complete to Flyway style. In this case you will setup our database with Flyway than take a snapshot of your database with dbunit and use this snaphot in your test. This must always be done with each schema migration!

Conclusion