Writing Test Cases for T-SQL Code

  • I'd love some articles that look at a piece of code you've written (query/batch/proc) and then what test cases or code you've put together to verify it works.

  • Are you still looking for something on this?

    I have an idea that works through the process of designing a SP to handle a parameterized query, based on the best practice suggested by Gail Shaw in her SQL in the Wild article on Catch All Queries[/url].


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Yep, I'd actually like a few of these.

    If you can put something together that tests some of the various possibilities for code, whether this is a variety of parameters or separate testing sprocs, that would be good.

  • As I have a hot idea in my head I'll work on it this weekend.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Article submitted!

    Design, Build and Test a Dynamic Search Stored Procedure

    It's a long one.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Thanks, I'll take a look next week

  • I made a rather small but silly mis-statement which I have corrected and resubmitted.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Bump.

    We are looking for more articles, but in a real situation where you've written a test for your code. We want examples people can learn from.

  • Are you still looking for articles in this vein? I've been overhauling a lot of my organization's unit test infrastructure and thinking about what makes for good and useful tests as I work through them. I've one example where I took a mostly useless unit test and overhauled it to provide greater value, and thanks to source control, I can probably replicate the steps easily enough.

    I've also been stretching the limits of what I can do with unit tests and the SSIS Catalog...

  • I would like some. I'd like to have an article that focuses on a particular test, why it's written, what it catches, or has caught.

    Multiple articles is fine. Using any test framework.

  • bump

  • Steve, you still looking? Trying to larn me sumthin', wondered if maybe I should document my crash and burn approach to TDD and CI along the way? Might be more entertainment than educational, but I'm sure the resulting commentary will help push me in new directions too.

    -------------------------------------------------------------------------------------------------------------------------------------
    Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses

  • Would love to see that. Always want new testing articles. Be nice to focus on an overall process with an example, but would appreciate other articles that show how to test case x or case y.

Viewing 13 posts - 1 through 12 (of 12 total)

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