473,321 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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

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
Nov 19 '05 #1
3 1581
look at mbunit

-- bruce (sqlwork.com)

"Sasha" <no*****@noemail.com> wrote in message
news:O2**************@TK2MSFTNGP15.phx.gbl...
| 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
Nov 19 '05 #2
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" <no*****@noemail.com> wrote in message
news:O2**************@TK2MSFTNGP15.phx.gbl...
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

Nov 19 '05 #3
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 <no*****@noemail.com> 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


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Berthold Hoellmann | last post by:
Hello, When I use ./configure --with-thread --with-fpectl --with-signal-module \ --with-pymalloc --enable-shared --with-cxx=g++ make test on 2.3.3 I get
0
by: Remy Blank | last post by:
Ok, here we go. I added the possibility for tests using the unittest.py framework to be skipped. Basically, I added two methods to TestCase: TestCase.skip(msg): skips unconditionally...
4
by: Edvard Majakari | last post by:
Hi, I just found py.test and converted a large unit test module to py.test format (which is actually almost-no-format-at-all, but I won't get there now). Having 348 test cases in the module and...
41
by: Roy Smith | last post by:
I've used the standard unittest (pyunit) module on a few projects in the past and have always thought it basicly worked fine but was just a little too complicated for what it did. I'm starting a...
0
by: Andrea M. Segovia | last post by:
I just compiled (but did not install) perl 5.8.0 on an SGI Origin 300 server (IP35) running IRIX 6.5.20m. Make test reported one test error, which I narrowed down to .../lib/ExUtils/t/Constant.t...
0
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** ...
6
by: ypjofficial | last post by:
HI, I have following terrific confusion. class test { public: int i; int * j; int **k;
2
by: Netkiller | last post by:
#!/usr/bin/python # -*- coding: utf-8 -*- """ Project: Network News Transport Protocol Server Program Description: 基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
7
by: laura | last post by:
Hi, I have a variable of type double. I need to know if there is an integer number store there. How can I test that ? I also have a default precision for doing this operation. Many thanks,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.