Rollback database after integration (Selenium) tests

落花浮王杯 提交于 2019-11-30 00:49:50

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.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!