Putting Unit Tests to Work

  • Comments posted here are about the content posted at http://www.sqlservercentral.com/columnists/gFritchey/2805.asp

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

  • Thanks -- the content was very good.  The format, however, (I'm sure not the fault of the author) made the article unprintable, and difficult to read on screen. At least my hand-eye coordination is poor enough that having to scroll way to the right to follow a line of text and then way back to the left margin to read the next gives me a fit. I'm glad the code doesn't break in arbitrary places, but the narrative ought to fit in a screen.

  • Thank you.

    Yeah, I've noticed the same thing. When a line of code extends past the edge of the screen it shoots ALL the text out there too. It does make things hard to read. I wonder if the powers that be can do anything about it?

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

  • Blush...I just found the "Print This!" icon on the article (top). Gives a much better format for printing and reading!

  • Now we're both learning. I never noticed that before either.

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

  • Thanks Grant, this is a great article. Slightly on, and slightly off topic: I'm trying to convince my bosses that this would be a good idea. This being DBPro. How much of the whole For Professionals system do you have to implement to make this happen? Can I just install the IDE, and get all the unit test stuff working, or do I need to install the server side as well?

    Thanks,


    Rick Todd

  • You get all the functionality I've talked about without any of the server components. The server adds in all the Team activities like Work Items, Team builds, shared documents, etc.. I actually haven't used it much, so I'm not too familiar with it.

    You get the DBPro install done & you can build & deploy databases, unit testing, generate test data (maybe the next article), etc. BTW, you'll need to beat your Microsoft rep about the face & neck to get them to admit it, but you don't need the Team Suite in order to install & run DBPro. You'll see a substantial savings on an already very expensive tool if you take the time & trouble to give them a good thrashing (plus, it's fun).

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

  • <Rick Todd>Can I just install the IDE, and get all the unit test stuff working, or do I need to install the server side as well?</Rick Todd>

    You shouldn't need to install a Team Foundation Server but I believe you need to have one of the Team System products installed on your workstation. It might be worth pushing for a Team Foundation Server though; it's worth just to get rid of SourceSafe! However, if you've already switched to another source control system it might not be as big of a sell to you or your management.

    [Edit]Grant beat me to the punch and notes that you can lay DBPro on a Non-Team System Visual Studio installation.

    [font="Tahoma"]Bryant E. Byrd, BSSE MCDBA MCAD[/font]
    Business Intelligence Administrator
    MSBI Administration Blog

  • Tatsu,

    As far as I'm aware, you will need Team System for Database Professionals Edition, but not the "Suite", which is the much more expensive package that includes all four Editions (Architect,Dev,Test,DB).

    Someone please correct me if I'm wrong.

    David

  • You're 100% correct.

    I actually thought that was what I said.

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

  • I'm not a .Net guy either... that's why I just right click on a proc in QA and select [OPEN].  A windows opens with all the parameters available which can be filled in.  When you finally select execute, it opens a new query window with the code the system wrote to do the test. 

    Not sure if we're talking the same thing, though...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • I like the idea of formal unit testing, although I'm yet to be convinced that it's something that many database devleopers have seriously tried to adopt, although this could be because there are not enough tools like DBPro and TSQLUnit that provide an easy-to-use framework from which tests can be authored and run.

    I'm curious know how DBPro unit testing compares to TSQLUnit? Are there pros and cons to their respective approaches?

    David

     

     

  • I've used both (and wrote articles on both). I think the TSQLUnit is a more pure version of unit testing than DBPro. TSQLUnit also has pretty good reporting capabilities on the results of multiple tests.

    DBPro is a lot easier to use and more easily extended than TSQLUnit. Then there's the convenience factor. As someone noted above, right click on a proc and you've got a unit test with parameters built in. Too easy.

    I don't know that we'll write formal unit tests for all our procs, but we know that some apps or some procs within apps are candidates for frequent tweaks during development. So, those we get tests for. They've proved invaluable. I just recently rewrote a series of procs from an old project. I created tests for procedure with a before & after run through the data compare extension. I was able to validate these procedures as I went which convinced the business unit that I wasn't ruining their lives but rather improving them.

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

  • Hi,

    I have implemented the code pretty much as written, but am having trouble getting the test condition registered. 

    Your article does not describe how to add the assembly to the GAC, or to generate the public key that you have in the xml, but I found this info in Sachin's original article.  It would be helpful to see this info in your article, as well as a suggestion for how to name your project at the start.

    I do think that you mistyped the line

    <extension type="TablesEqual.TablesEqual" enabled="true" />

    in your xml file: Assuming that you named your assembly TablesEqual, shouldn't you use TablesEqual.DataEqual?

    There is also a disagreement between your article and Sachin's about where to put the xml file.  He says the DBPro directory, you say the MSVSTEDB - ENU directory.

    On to my problem - I have the code compiled into a DLL.  I have run gacutil and have copied the public key into the xml file.  I've put the xml file in both directories suggested above, and still have no luck in getting the condition to show up in my tests.  I've tried creating new test projects and also tried manually adding my dll as a reference for the test project.  None of this seems to work.

    Any suggestions?

    Mark

  • I think you're correct on my errors in the article. Thanks for the input. I'm not sure if Steve will let me do an update, but I'll check.

    I suspect it's the XML. Every time I've had a problem, that's been where it resided. One other issue, the code I wrote was against the CTP6 version of the software. Several small things changed with the release, especially some of the formatting for the XML file. Check the online documentation to verify what you have is the latest format.

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic. Login to reply