title: Automatically Updating Database Schema For Java Project's Unit Tests
body: <p>
  I've got a Java project that needs to populate the database with a new schema prior to executing Unit Tests.  Maven is used to build the project.  Unitils is used for the unit tests.
  </p>
  
  <p>
  My plan was to execute the following scripts, in this order:
  <ol>
  <li>Drop/Create database script (dropcreate.sql)</li>
  <li>Schema script (schema.sql)</li>
  <li>Reference data script (reference.sql)</li>
  </ol>
  </p>
  
  <p>
  As a side benefit I can see if the reference data script no longer matches the schema if it fails to execute.
  </p>
  
  <p>
  I have used the hibernate3 plugin for Maven to generate the schema script at build time.  I've also used the maven-antrun-plugin to copy these scripts all into the same directory (target/dbscripts) with numbers in order of execution, like so:
  <ul>
  <li>001_dropcreate.sql</li>
  <li>002_schema.sql</li>
  <li>003_reference.sql</li>
  </ul>
  </p>
  
  <p>
  The plan was to have the DBMaintainer portion of unitils run the scripts, as noted at <a href="http://www.unitils.org/tutorial.html" rel="nofollow">Unitils Tutorial</a>, by using the following (sanitised) unitils.properties file in src/test/resources:
  <pre>
  database.driverClassName=com.sybase.jdbc3.jdbc.SybDriver
  database.url=jdbc:sybase:Tds:mydatabase.server.example.com:9000/my_database
  database.userName=myusername
  database.password=mypassword
  database.dialect=org.hibernate.dialect.SybaseDialect
  database.schemaNames=dbo
  DatabaseModule.Transactional.value.default=disabled
  org.unitils.core.dbsupport.DbSupport.implClassName=org.unitils.core.dbsupport.MsSqlDbSupport
  DbUnitModule.DataSet.loadStrategy.default=com.example.dao.SybaseCleanInsertLoadStrategy
  updateDataBaseSchema.enabled=true
  dbMaintainer.script.locations=target/dbscripts
  dbMaintainer.cleanDb.enabled=true
  dataSetStructureGenerator.xsd.dirName=target/xsd
  </pre>
  </p>
  
  <p>
  Unitils loads datasets and conducts the unit tests fine, but it never seems to run the scripts.  I'm sure it's something simple I'm overlooking.
  </p>
  
  <p>
  An alternative was to use the sql-maven-plugin, but I couldn't get it to execute during process-test-resources, so I've tabled that idea for now.
  </p>
  
  <p>
  How do I get Unitils to actually execute the SQL, and, if possible, fail if the SQL cannot be executed?
  </p>