Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


An Introduction to Test Driven Development


An Introduction to Test Driven Development

Author
Message
cutespn
cutespn
SSC-Enthusiastic
SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)SSC-Enthusiastic (125 reputation)

Group: General Forum Members
Points: 125 Visits: 20
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/sPalyam/anintroductiontotestdrivendevelopment.asp






Regards,
Sudheer

My Blog


hurcane
hurcane
SSC-Enthusiastic
SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)

Group: General Forum Members
Points: 145 Visits: 254
I looked at tsqlunit. With VS2005, I think it is easier to use NUnit to test our stored procedures. Here's what we've done (VB.NET code)...

1) Created an NUnit test fixture that utilizes SWC (Services Without Components) and transactions. This works for us because all of our development PCs are on Windows XP. Here's the basic transaction class.

Imports NUnit.Framework
Imports System.Transactions
Imports TrulinX.SA

Public MustInherit Class TransactionFixture
Private tx As CommittableTransaction
<SetUp()> _
Public Sub Setup()
tx = New CommittableTransaction
' Make the transaction the ambient transaction.
' ADO.NET and COM+ will automatically participate
' with this ambient transaction.
Transaction.Current = tx
End Sub

<TearDown()> _
Public Sub TearDown()
tx.Rollback()
End Sub
End Class

2) All test cases that use the database inherit from TransactionFixture. This provides automatic rollback capability.

3) It's still a lot of work to set up test data. But we don't have to worry about cleaning it up because all the work is automatically rolled back.

4) Refactor, refactor, refactor! The same Insert statement may be useful in 20 different tests. Don't copy it. Centralize it in a utility module.

Our inspiration came from "Test-Driven Development in Microsoft.NET", by James Newkirk and Alexei Vorontsov. Additional inspiration came from the many bloggers who wrote about the amazing new features in Visual Studio 2005.



Tatsu
Tatsu
Old Hand
Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)Old Hand (302 reputation)

Group: General Forum Members
Points: 302 Visits: 307

Don't forget these two resources:

I like to use MBUnit to run the tests in a console app that brings up a web page with the results of the test run. I haven't used TestDriven.net much yet but I plan on getting into it when I finish my degree next month and have some time to mess with it more seriously.



Bryant E. Byrd, BSSE MCDBA MCAD
Business Intelligence Administrator
MSBI Administration Blog
mosaic-287947
mosaic-287947
SSC Veteran
SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)

Group: General Forum Members
Points: 220 Visits: 806

This "simple" example of an uppercase stored proc is a very good choice for another reason: testing just one string will not be enough. A company with users in more than one country would need to use test data in the languages of all its major customers - including those with character sets that may not even have the concept of uppercase. Collecting realistic test data could be a major effort in itself, but once that is done a TDD environment would have no problem processing it.

Although I can see the benefit of formal TDD, it does add a considerable overhead in tools, training, storage, reporting and the like. It assumes that the complex infrastructure that was in place during the initial development will still be there when version 2 comes along. This may not be the case for small to medium-size projects. Also, when the focus shifts to testability, what happens to the other "ilities" like scalability and maintainability?


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search