Back at Trimble, I wanted to write some unit tests for our DAO stuff, so I came up with this crazy scheme to run a test SQL server on the local machine. I had all this custom code set up to prep the database for the test, then run the tests.
In Java, I am using a HypersonicSQL (is it even called that anymore?) in-memory database to do testing. It’s really fast since it doesn’t write to disk, and every time you run the tests, you have a fresh database. You just inject the HSQL config into the HibernateUtil class and run the tests.