Tuesday, 30 September 2008
Unit Testing Linq To Entities
We have decided that we're going to use Linq to Entities and the Entity Framework Model in our new project. This means that for our model we are going to have to create unit tests that mimic the database environment. We don't want our unit tests to connect to the database itself because that will make the unit tests unnecessarily lengthy and put the developers in a position where they will avoid doing the unit tests where possible. Also when doing unit testing against the database you must make sure that the data int he database is correct before doing the unit test.
The solution is to create your own data in code or with XML that you can test against reliably. I came across this blog by Ian Cooper that goes trough a fantastic way to create your own data in exactly this fashion.
If you're using Linq to Entities or Linq to SQL and you are trying to follow TDD, I highly recommend reading this blog.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment