Hacker News new | ask | show | jobs
by afarrell 3185 days ago
> which depends on fast setup and teardown

In postgres at least, Wouldn't your framework create a db transaction that then is rolled back at the end of the test?

1 comments

That only works if the code you are testing does everything in auto-commit mode. Which is often a terrible idea. If your code uses transactions, then no, the framework cannot rely on rollback to do setup and teardown.
I use django with transactions and tests work fine. I think a transaction within a transaction is treated as a checkpoint.
Tests with transactions works fine in rails/rspec.