• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting maven to create my DB before tests are run

 
Ronan Dowd
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Am using maven 2.0.8..

Before running my JUnit test suite via maven (i.e. mvn surefire-report:report).. I want maven to first create my database schema for me as all my tests persist
into this database. I don't want the user to have to manually create the test schema before executing the tests. I have a file "create_schema.sql" which i want maven
to execute in the generate-test-resources lifecycle (if thats the correct place). Can anyone point me in the direction of an example where something like this is done

Any help would be great.
Thanks, Ro.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18226
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should look into one of the database-related unit-testing frameworks like dbunit.

These frameworks make for repeatable database tests by setting up up the database, loading initial data, running the tests, then deleting the data so that you have a clean venue for the next test cycle with no leftovers to pollute things. Commonly, they'll also hook to a lightweight database that runs locally so that you can do these tests without needing access to a heavyweight database server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic