• Eric M Russell (8/23/2016)


    It sounds like you're describing some specific implementation of unit testing within SSDT or Visual Studio.

    Unit Testing a stored procedure, generally speaking, is when you execute a stored procedure using a set of input parameters and then confirm that the output or sequence of DML operations match a documented result. This can be done manually though a SSMS query window or using a special unit testing tool.

    For example, here I'm unit testing a procedure called usp_CityPopulation_List, confirming the result contains the top 5 populated cities in the US ranked in descending order by population size.

    EXEC usp_CityPopulation_List @country = 'US', @toprank = 5;

    New York 8,550,405

    Los Angeles 3,971,883

    Chicago 2,720,546

    Houston 2,296,224

    Philadelphia 1,567,442

    I typically include a few unit tests within the header comments of my stored procedures.

    I'm with you, my unit test for SPs has always been a manual thing for me.

    I'll simply execute the Stored proc. with different parameter inputs if there are and based on the result set its right or wrong.

    Once I'm happy a tester will come in and do it from the Application itself. any issues they will then do the same thing on the SP to determine where the problem is caused.