• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting maven to create my DB before tests are run

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic