File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes getting maven to create my DB before tests are run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "getting maven to create my DB before tests are run" Watch "getting maven to create my DB before tests are run" New topic
Author

getting maven to create my DB before tests are run

Ronan Dowd
Ranch Hand

Joined: Jan 21, 2006
Posts: 84
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.


SCJP 1.4 | OCWCD JEE 5
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting maven to create my DB before tests are run