3 ms·
If I'm using Django I let Django's default test harness handle that for me - it runs each test in a transaction and rolls it back at the end of the test, which
by simonw 3y ago
If I'm using Django I let Django's default test harness handle that for me - it runs each test in a transaction and rolls it back at the end of the test, which is pretty fast. https://docs.djangoproject.com/en/5.0/topics/testing/overview/ https://docs.djangoproject.com/en/5.0/topics/testing/overvie...
For my other projects I'm generally using SQLite where starting a new in-memory database is so fast it's effectively free.
- dkdbejwi383 3y agoHow does that work when the system under test uses transactions itself?
- simonw 3y agoA lot of databases these days support nested transactions using savepoints, which Django's test framework can take advantage of. There's a separate mechanism for writing tests where you need to explicitly test transaction mechanics: https://docs.djangoproject.com/en/5.0/topics/testing/tools/#django.test.TransactionTestCase https://docs.djangoproject.com/en/5.0/topics/testing/tools/#...