So, I'm developing some database-driven RESTful Java web services, using Hibernate and MySQL.  For testing purposes, I'm using the H2 in-memory database.  H2 is nice and fast, so this has worked out really well.  The only problem is that populating the DB tables prior to my tests is sort of tedious.  I basically create and persist a bunch of objects by hand.  I'm wondering if maybe I'm going down the wrong road.Please tell me, what are the best practices for doing what I'm trying to do?  Any tools that could help me?  Any general strategies or tips?
What are some best practices for populating and using a test database?
java;database;unit testing;orm;tests
I'm going to assume you've designed your API so you can DI your DB details, if not then we can help you through that.In terms of terminology, you're wanting to use a Fake Test Double. In this particular case, I'd recommend using the same in-memory DB (H2), but use DBUnit to work with JUnit in order to create your tables, populate them before each test, truncate the data after each test and then finally teardown the tables once your TestSuite is finished.There are other solutions such as Grails and Spring Roo which create some test data for you, but DBUnit will work a treat for you now.