> > My, granted very small, test suite now takes ~1.1s on postgres and > > ~0.6s with H2. So, almost 2x as fast. Not a big deal now, but on > > larger test suites, that will be nice. > > A bit off-topic here: > > For Postgres you could setup your schema in a template database. When > you want to run your tests, you simply drop your test database and > create a new one based on the template. That gets rid of everything. > If the schema changes, you only adjust the template database.
Thanks for the suggestion; I had not thought of that. On my current small schema, making a new one via a template takes ~200ms. That is not bad. But calling a generated "flush_test_database" stored procedure that just has all of the "DELETE" statements hardcoded takes ~10ms. (Which is an improvement over our original approach--the prior codebase executed each DELETE via JDBC, which with ~200 tables got to be a lot of chatter that the stored procedure cut down on.) > Might be something to look into for you. Yeah, thanks, I enjoyed trying it. Always looking to shave time here and there. :-) While off topic, the ultimate time saver is to start a transaction in setUp, never commit (only flush) in your testXxx method, and then rollback in your tearDown. I first heard of this in the Rails community, but now a Spring/Hibernate project I was on was using/abusing it as well. I can appreciate the increased speed, but I'd rather be completely sure my tests worked by committing the data and then deleting it back out. (...something like cross-connection/db-wide savepoints would be great for this sort of stuff.) - Stephen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/h2-database?hl=en -~----------~----~----~----~------~----~------~--~---
