tSQLt : How to compare result set (dynamic column return) from call stored procedure without define the structure table

56 Views Asked by At

Please help me to compare the result set(dynamic columns) from caller stored procedure without define the structure table using tSQLt

SP:

ALTER   PROCEDURE [dbo].[spa_Test]
    @Param1 INT 
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    IF @Param1 = 1
    BEGIN
        SELECT [A] = 123 FROM Position  
    END
    ELSE IF @Param1 = 2
    BEGIN
        SELECT [A] = 321, [B] = 534 FROM Position
    END 
    ELSE
    BEGIN
        SELECT [C] = 456, [D] = 896, [E] = 434 FROM Position
    END 
END

Compare result for 2 result(without define structure table to catch result set), have another way without define structure before?

CREATE OR ALTER PROCEDURE TestProcedureModification.TestCompareResult
AS
BEGIN
    EXEC tSQLt.AssertEqualsTable 'EXEC spa_Test @Param1 = 1', 'EXEC spa_Test @Param1 = 2' --Error
END;
GO
EXEC tSQLt.RunTestClass 'TestProcedureModification.TestCompareResult'

0

There are 0 best solutions below