The World’s Leading Microsoft .NET Magazine
   
 
timstall

Donate Today!

Search Box

 

Calendar

««Mar 2010»»
SMTWTFS
  12
3
456
7
8
9
10
111213
14151617181920
21222324252627
28293031

My RSS Feeds








Mailing List

Most Popular Tags

                                                           

Unit Testing the Data Access Layer

posted Tuesday, 5 April 2005

I had the opportunity to write an article for 4guysfromrolla - "Unit Testing the Data Access Layer".

"Unit testing is becoming very popular among .NET projects, but unit testing the Data Access Layer (DAL) still remains a common obstacle. The problem stems from the very nature of databases: they are slow, common, persistent, external, and relational. This conflicts the nature of unit tests, which should be quick, independent, and repeatable..."

You can read the entire article on the 4GFR website at:

http://aspnet.4guysfromrolla.com/articles/040605-1.aspx

links: digg this    technorati    




1. a reader left...
Thursday, 7 April 2005 10:56 am

Great article; I'll find this very useful. I liked how you explained the two methods - RunScript and RecreateDBSchema, and then provided practical examples.

Mark


2. a reader left...
Friday, 20 May 2005 7:30 pm

I believe that any DataLayer must be a simple code block, that they allow operations against DB.

That code block would not have to know on the Business Entities. Single to specialize it is to execute the operations (Store Procedures and SQL Sentences) against the engine DB (SQL, Oracle, DB2, etc.), with which this setting.

Finally, I invite to you to download the DataLayer.Primitives Public Version.

This is very cool Data Layer :)

DataLayer.Primitives - Readme!
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=1389

Cheers,

Javier Luna
http://guydotnetxmlwebservices.blogspot.com/

Javier Luna


3. Mike Brockey left...
Friday, 13 October 2006 4:11 pm :: http://blogs.ent0.com/blogs/mikebrockey/

Hi Tim - Very good article! We have come up with a way to snapshot the database, track changes and then put the database back into a known state. dataFresh is an API that integrates directly into your test framework and will very quickly restore only those tables that were modified. Check out my blog for the details!

http://blogs.ent0.com/blogs/datafresh/default.aspx


4. Db UnitTest left...
Tuesday, 21 April 2009 1:50 am

It is a very good article, And now I am glad to share one database unit testing tool. It is named as AnyDbTest (<a href="http://www.anydbtest.com">www.anydbtest.com</a>). AnyDbTest 2.1 brings a wide-ranging set of improvements. AnyDbTest Express edition is free of charge.

I know some guys are using DbUnit or other xUnit test framework to perform DB unit testing. I also tried to use them in my projects, but at last I had to give up these tools because I must keep focus on the database rather than switch to be as application developer.

AnyDbTest is declarative style testing tool. We will not need to program at all. What we do is to express what we want to test, rather than how to test. We only need to configure an Xml test file to tell AnyDbTest what we want to test. Rather than painstakingly writing test code for xUnit test framework. So AnyDbTest is the right choice for DBA or DB developers.

AnyDbTest also offers a visual dashboard. Success or failure of test is automatically computed and presented to us via an easy-to-understand red/green light display.

Features specific to AnyDbTest: *Writing test case with Xml, rather than Java/C++/C#/VB test case code. *Many kinds of assertion supported, such as StrictEqual, SetEqual, IsSupersetOf, Overlaps, and RecordCountEqual etc. *Allows using Excel spreadsheet/Xml as the source of the data for the tests. *Supports Sandbox test model, if test will be done in sandbox, all database operations will be rolled back meaning any changes will be undone. *Unique cross-different-type-database testing, which means target and reference result set can come from two databases, even one is SQL Server, another is Oracle.