Unit tests must be as clearer as possible, I found that in standard project I’m working, I use nhibernate + stored procedures for massive operations. Most of the tests contains code to preload database, recreate structure or manage transaction, so, lot of time ago I decided to build some infrastructure to make this possible.
It makes my test really simple to read. This test use SqlServer, and it needs to be transactional, so every test run inside a Transaction, but I can specify more complex stuff
I can ask to clear the database at each test, I can ask also to execute all the tests with integrity check disabled, and also I’m able to make the test impersonate specific user, belonging to specific role.
I know that spending some time, building an infrastructure for your test can give you great value.
Tags: Unit Testing