I\'m just trying to add test cases for services accessing a MySQL DB, and I would like to recreate the whole schema (and for some scenarios also just use a MySQL dump file w
We use MySQL and flyway to handle the migration.
For unit testing and simple integration tests, we use the H2 in-memory database with the MODE=MySQL
param. Mode=MySQL
enables the H2 DB to handle most of the MySQL dialect.
Our test datasource in the Spring config is set up like this:
(If you don't know Spring - the XML translates into calling new BasicDataSource
and then call setDriverClassName
and setUrl
on the instance created)
Then we use Flyway on the datasource to create the schema and read in like we would against a regular MySQL DB:
You could also just use the dataSource bean in a jdbcTemplate and run some SQL scripts that way or run a number of MySQL scripts using the
tag.