SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


An Example of Test-Driven Development


An Example of Test-Driven Development

Author
Message
steve smith-401573
steve smith-401573
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2553 Visits: 744
Wonderful article. I followed you completely up until almost the last sentence - where you used the ambiguous term 'opposite' in the Q&A section:

'Scripting the database will work wherever restoring a backup will work, but the opposite doesn't always hold.'

Which logical opposite? Are you saying that scripting will not work wherever a backup will not work, or that scripting will not work wherever a backup will work, or that a backup will not work where scripting does (not) work, or ....

And, how would you build a (syntactic) test script for that sentence anyway?

Great job!
mike brockington
mike brockington
SSC Veteran
SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)

Group: General Forum Members
Points: 260 Visits: 245
Great explanation of 'how' but could have done with a bit more info one exactly 'why' to do things like this.
As far as I can see, writing the test first is a waste of time if it is being done by the same person as is developing the code: if you know what to test for, then you know how to write code that will pass, and will stop improving the code when it passes all of the tests.
By testing after the code is written, you get a chance to write additional tests when you have seen odd behaviour.
If you have the luxury of a seperate testing team, then there is no point bringing them in before any code has been written - that is what a design is supposed to be for!

Throw away your pocket calculators; visit www.calcResult.com


Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)

Group: General Forum Members
Points: 98636 Visits: 38996
I'd suggest doing more reading on Test Driven Development before passing judgement. If done correctly, TTD is a good development methodology. The problem I see with it is the abuse that is possible, which one problem is writing of tests such that the code will pass.

The tests are supposed to be written first based on the users requirements. The code is then written and tested using those tests. Of cousre, you may miss some things this way also.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
SRDEV
SRDEV
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 28
I thought it was pretty good. Too bad you didn't see the point.

I would be more concerned about your thoughts on the testing team. I would be pretty upset if the testing team was allowed to create tests as they go and keep changing the requirement. Is that what you want from a test team, to keep sending your programs back to development?

I think this is really informal "testing" as a development process. Maybe there could be a better word for it. But, hopefully there are some requirements before you start. One key objective (at least in project management) is NOT to build more than is required. Someone should be responsible for specifying the requirements before development. Yes, it can specify some standard useability in general. But, work shouldn't come back for more and better ideas.
mike brockington
mike brockington
SSC Veteran
SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)

Group: General Forum Members
Points: 260 Visits: 245
@Lynn
Maybe I should have made it explicit that my comments were based on experience, not on conjecture.
If the OP thinks it works well, I would be interested to hear what was different about his setup.

@SRDEV
Sorry, I don't follow what you are getting at.

Throw away your pocket calculators; visit www.calcResult.com


Andy Leonard
Andy Leonard
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2427 Visits: 1102
Test-Driven Development doesn't work in every situation. In my experience, nothing works in every situation. That's one of the reasons I titled the article "An Example..." in the first place.

My goal in this article is to introduce the concepts. Granted, the example lacks practical application in most scenarios. But there are benefits to this approach that I explore in the next part of the article.

Hang in here with me. All of this probably won't work for you, but I bet pieces of it will.

:{> Andy

Andy Leonard
Data Philosopher, Enterprise Data & Analytics
Max-146500
Max-146500
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1219 Visits: 363
Andy Leonard (5/6/2009)
Hang in here with me. All of this probably won't work for you, but I bet pieces of it will.


Would that include purchasing Team System licenses and going the dbpro development route forcing your database developers to develop in Visual Studio, deploying database changes using team system, no access to real data or databases? What's your next sales pitch: "If you don't use source or version control, I predict you will one day." {whether you want to or not} you should have added.

It never fails to amuse me how many different angles this comes from.

Max
Andy Leonard
Andy Leonard
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2427 Visits: 1102
Hi Max,

There are different mindsets for DBAs and database developers. There's stuff they share, and stuff that one can learn from the other. It's folly to assume DBAs are going to think like database developers or database developers are going to think like DBAs.
All this means, in this context, is: People in our field are going to react differently to the idea of test-driven database development.

Regarding Team System: If you've been working with SQL Server for a while, you can see a pattern in the tools emerging. If you worked with DTS in SQL Server 2000, you did that in Enterprise Manager - the same place you did a lot of enterprise DBA tasks. With SQL Server 2005 came SSIS, and along with it a version of Visual Studio for developing SSIS.
Can you do SSIS development inside SQL Server Management Studio? Yes - and you do, in fact, whenever you create a Maintenance Plan. So if it's possible inside there, why not leave it all there?

My thinking is Microsoft is attempting to sever purely development activities from administrative activities. If I was a betting man, I'd bet the trend will continue. If that bugs you, you may be bugged.

Database Edition is free with Developer Edition as of October 2008. A full Team System license isn't required unless you're wanting to do other Team System stuff (and then it's justified for those reasons).

As for source control, you may not like it - many do not - but it's a reality for most database and application developers. Beyond the legal / auditing requirements, source control is just a good idea. I doubt seriously you'd question the assertion you should backup your database. One (merely one) benefit of source control is it backs up your business logic.

:{> Andy

Andy Leonard
Data Philosopher, Enterprise Data & Analytics
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)

Group: General Forum Members
Points: 98636 Visits: 38996
mike brockington (5/6/2009)
@Lynn
Maybe I should have made it explicit that my comments were based on experience, not on conjecture.
If the OP thinks it works well, I would be interested to hear what was different about his setup.

@SRDEV
Sorry, I don't follow what you are getting at.


A previous employer implemented TDD for their projects. A co-worker from there said it didn't work but explained why. The developers wrote their tests to pass their code which isn't how it is supposed to work.

Maybe it didn't work for you, but that doesn't invalidate the methodology, just the implementation you were working under.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Max-146500
Max-146500
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1219 Visits: 363
I see you've had to try and justify this all before, and yes, I've heard it all before too.

Suggesting that I'm just not with it isn't good enough Andy. My company has been struggling for over two years now to get VSTS and dbpro integrated as part of our development lifecycle and that includes all aspects of it right down to customised SSRS reporting based on the Team System database and cube and I'm strongly suggesting that it's an immature product that isn't ready for market yet. Why did we go down this route despite the incredible cost in money, time and sanity? well because of "legal / auditing requirements" paranoia. I know another company who had similar issues and eventually had the common sense to pull out before their evangelists started suggesting it was the team who were wrong and not them. But hey, if you want to be responsible for costing your company millions of squids in times like these and getting nowhere for greater overheads, be my guest.

Here's my suggestion:
- If you want to back up your databases (presuming you don't have a maintenance plan) and you prefer having your database comprised of a collection of text files, why not script them out and hey presto there's, thrown into the bargain, your auditing trail (see SQLCompare).
- If you want a customisable quantifiable work register see Fogbugz.
- If you want a refactoring tool, write one, I have.
- If you really like checking things in see TortoiseSVN.

I just don't see how defining duties between dba's and developers (BI included) based on the current product suite will herald a grand new future. Frankly, I think it's irresponsible of MS to release such an immature product.

There goes my invite to the next developer forum Doze

Max
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