I'm using optimistic database locking in an event store database. I want to write an integrative test verifying the ConcurrencyException
handler code.
What's a good way to force such situations in tests?
My ideas so far:
- Try running many parallel transactions and hope for a
ConcurrencyException
- however, such a test would be inherently "flaky" and would sometimes fail. - Add an extension point
BeforeCommit
to my subject under test and delay the actual commit until another transaction is finished. However, this would force me to introduce an extension point very deep in my class hierarchy only for testing purposes.
Any other good ideas?
Aucun commentaire:
Enregistrer un commentaire