Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Test-Driven Development with Databases, what is the best way to doit?

Reply
Thread Tools

Test-Driven Development with Databases, what is the best way to doit?

 
 
Sasha
Guest
Posts: n/a
 
      03-02-2005
Hi everybody,

I am starting a new ASP.NET/SQL Server project and this time I want to
do it through Test-Driven Development (TDD). The problem that I ran into
is this: How do you test data access logic with a database in the
backend? I do not want to use mock objects because if the schema changes
I will miss those errors.

If you are using TDD to test data access code, please post the
description of your setup or some pointers and suggestions.

Thank you very much for your help!

Sasha
 
Reply With Quote
 
 
 
 
Manohar Kamath
Guest
Posts: n/a
 
      03-02-2005
Without Mock objects, testing the DAL is challenging. One way I would do it
is:

1. Unit test your database code separately -- using something like
T-SQLUnit.
2. Create a "baseline" database to test your DAL objects
3. Write unit-tests for your DAL objects. Make sure that after each test,
the database returns to the original state -- using TearDown.

The most challenging parts I found were if you were using identity columns,
and want to unit test object IDs.

Hope that helps, but if you find a better answer please post it to the
newsgroup.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com


"Sasha" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi everybody,
>
> I am starting a new ASP.NET/SQL Server project and this time I want to
> do it through Test-Driven Development (TDD). The problem that I ran into
> is this: How do you test data access logic with a database in the
> backend? I do not want to use mock objects because if the schema changes
> I will miss those errors.
>
> If you are using TDD to test data access code, please post the
> description of your setup or some pointers and suggestions.
>
> Thank you very much for your help!
>
> Sasha



 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      03-02-2005
look at mbunit

-- bruce (sqlwork.com)

"Sasha" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| Hi everybody,
|
| I am starting a new ASP.NET/SQL Server project and this time I want to
| do it through Test-Driven Development (TDD). The problem that I ran into
| is this: How do you test data access logic with a database in the
| backend? I do not want to use mock objects because if the schema changes
| I will miss those errors.
|
| If you are using TDD to test data access code, please post the
| description of your setup or some pointers and suggestions.
|
| Thank you very much for your help!
|
| Sasha


 
Reply With Quote
 
Scott Allen
Guest
Posts: n/a
 
      03-02-2005
Hi Sasha:

Two thoughts to consider:

Depending on your design you could use an O/R mapper or code
generation tool to spit out code. There are advantages and
disadvantages to this approach, of course, but one of the advantages
is you'll have compile errors if the upper layer code is not keeping
up with the schema changes.

Unit testing code that needs access to the database can be tricky,
using mock objects doesn't solve all the problems of course but it can
remove some dependencies and make testing easier. One approach I've
seen used is to test against the real db, but wrap your test methods
with enterprise transactions, there is a discussion here:
http://weblogs.asp.net/rosherove/art...ittesting.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/


On Wed, 02 Mar 2005 11:29:04 -0800, Sasha <(E-Mail Removed)> wrote:

>Hi everybody,
>
>I am starting a new ASP.NET/SQL Server project and this time I want to
>do it through Test-Driven Development (TDD). The problem that I ran into
>is this: How do you test data access logic with a database in the
>backend? I do not want to use mock objects because if the schema changes
>I will miss those errors.
>
>If you are using TDD to test data access code, please post the
>description of your setup or some pointers and suggestions.
>
>Thank you very much for your help!
>
>Sasha


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Application development vs windows client development cabernet123@hotmail.com ASP .Net 0 11-17-2005 12:09 AM
enterprise application development versus traditional software development jrefactors@hotmail.com Java 2 01-15-2005 10:45 PM
development environment architecture for ASP.NET development team Akhlaq Khan ASP .Net 4 09-27-2004 01:33 PM
development process.... what is the best way ? Darren Clark ASP .Net 4 05-28-2004 03:56 AM
Re: Development best practices and knowing when to exercise control over development Kevin Spencer ASP .Net 2 08-06-2003 09:33 PM



Advertisments