Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««1234»»»

An Example of Test-Driven Development Expand / Collapse
Author
Message
Posted Thursday, April 30, 2009 12:17 PM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Friday, September 21, 2012 1:52 PM
Points: 696, Visits: 743
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!
Post #707898
Posted Tuesday, May 05, 2009 9:50 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, November 11, 2013 2:42 AM
Points: 150, 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

Post #710405
Posted Tuesday, May 05, 2009 9:59 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 5:45 PM
Points: 22,524, Visits: 30,284
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.



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)
Post #710415
Posted Tuesday, May 05, 2009 10:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 01, 2010 6:18 PM
Points: 7, 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.
Post #710421
Posted Wednesday, May 06, 2009 4:15 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, November 11, 2013 2:42 AM
Points: 150, 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

Post #710912
Posted Wednesday, May 06, 2009 8:16 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 1:39 PM
Points: 388, Visits: 1,034
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
CSO, Linchpin People
Follow me on Twitter: @AndyLeonard
Post #711114
Posted Wednesday, May 06, 2009 8:57 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 09, 2014 2:27 AM
Points: 280, Visits: 353
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
Post #711176
Posted Wednesday, May 06, 2009 9:41 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 1:39 PM
Points: 388, Visits: 1,034
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
CSO, Linchpin People
Follow me on Twitter: @AndyLeonard
Post #711233
Posted Wednesday, May 06, 2009 10:16 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 5:45 PM
Points: 22,524, Visits: 30,284
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.



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)
Post #711262
Posted Wednesday, May 06, 2009 10:36 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 09, 2014 2:27 AM
Points: 280, Visits: 353
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


Max
Post #711284
« Prev Topic | Next Topic »

Add to briefcase ««1234»»»

Permissions Expand / Collapse