SQLite and unit testing is a great combination for testing database operations without having to manage database files. You can simply create an in-memory database in your setup code and work with that. Perfect in combination with NHibernate for example.
If you want to do this in the current .Net 4.0 beta your out of luck though, you'll get an exception:
The solution is pointed out by Jomo Fisher. What you do is to include this snippet in the application config file:
When unit testing assemblies that references System.Data.SQLite.DLL then you have to put that snippet in NUnit's config file (C:\Program Files\NUnit 2.5.2\bin\net-2.0\nunit.exe.config).
If you combine this with the tip in my post NUnit with Visual Studio 2010 Beta 2, you should insert the following
plus
under the runtime tag.
This works for me, hopefully it will for you as well.
/Emil
[powered by WordPress.]
jour·nal n. A personal record of occurrences, experiences, and reflections kept on a regular basis; a diary.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jun | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
41 queries. 0.547 seconds
November 24th, 2009 at 1:20
Thanks for this Emil, it was very useful. System.Data.SQLite now happily working for me on 2010.
February 15th, 2010 at 0:33
Thanks a lot, i did a migration for my project from sqlce to sqlite and encountered this problem. Your solution worked.
February 18th, 2010 at 19:30
Trying to figure out how to get this to work with the resharper test runner
February 20th, 2010 at 13:23
Me too
If you're successful, please leave a note!
/Emil
August 13th, 2010 at 23:27
Thanks! I had the startup in my project config alongside my nunit file but didn't think that the nunit.exe.config would need it.
Awesome!
@mspspeak