|
|
|
|
|
by eloff
1884 days ago
|
|
Typically the approach I take is monkey patch out the transaction methods (begin, commit, rollback) in the test harnesses and wrap each test in a real transaction. Some test runners have this built in. This is easy in dynamic languages, really hard in in static languages. |
|
And because you abstracted all your transaction logic away for the tests, your test result is not worth anything.
IMHO, there are only 2 ways to achieve proper database testing: 1) new db for each test (very slow) or delete all data from all tables before the test (ok for smaller projects) 2) tests do absolutely have no impact on other tests with the data they added/modified/dropped (very hard to achieve).
Edit: typo