Rollback database after integration (Selenium) tests Rollback database after integration (Selenium) tests selenium selenium

Rollback database after integration (Selenium) tests


We are running a drop/create-table script before every test. This is quite fast and ensures that nothing is left from previous tests.

PS: We are using NHibernate, which creates this script on the fly and run the test on Sqlite in memory, it's lightspeed. But if we switch to SqlServer it's still quite fast.


It's a tough problem and the solution is typically unique for every app. Until the major frameworks adopt a "recommended approach", this will continue to be a pain.

My best recommendation: plan for this usage at the start of your app. Include APIs that clean up after the DB is reset from underneath the app (ie: reset caches).


There is a project called Amnesia (more docs, recent code) that is designed specifically for this scenario. It simplifies the process of using the MSDTC TransactionScope to rollback test changes. (Usage will require moderately invasive changes to data access in most applications, especially those not already using MSDTC.)