Why do SQL Test Messages appear doubled?

Easy unit testing for databases in SQL Server Management Studio

Moderators: JonathanWatts, David Atkinson, Anu Deshpande, Michelle Taylor, David Priddle

Why do SQL Test Messages appear doubled?

Postby bootieday » Tue Feb 11, 2014 10:18 pm

When a unit test fails, I see output like this (for AssertEqualsTable test with my own Failure msg). Why does the mismatched data appear twice in the SQL Test Messages window?

Test Class: foo
TestClassName.TestName failed: UPDATE expected table does not match actual
|_m_|col1|col2|col3|
+---+----+----+----+
|< |2 |B |b |
|> |2 |B |b |
UPDATE expected table does not match actual
|_m_|col1|col2|col3|
+---+----+----+----+
|< |2 |B |b |
|> |2 |B |b |
bootieday
 
Posts: 11
Joined: Tue Aug 30, 2005 2:14 pm

Postby Brian Donahue » Thu Feb 13, 2014 1:29 pm

What are the contents of the test stored procedure?

I am guessing that AssertEqualsTablewill write its' own failure output so it's not necessary to also write your own failure message.
Brian Donahue
 
Posts: 6668
Joined: Mon Aug 23, 2004 10:48 am

Postby David Priddle » Thu Feb 13, 2014 4:04 pm

Hi bootieday,

We've just released a beta build of SQL Test that should fix your issue with the duplication of test results in the messages window:

http://www.red-gate.com/MessageBoard/viewtopic.php?p=67784

Please let us know if this works for you!

Best regards,

David
David Priddle
 
Posts: 36
Joined: Tue Jan 28, 2014 10:22 am
Location: Red Gate Software, Cambridge

Postby bootieday » Thu Feb 13, 2014 7:14 pm

Here is a simplified version of what produces the doubled output. I tested it by removing the @FailMsg parameter and it is still doubled.

-- Tests the case of no rows returned from the dependent tables referenced by SELECT
-- For test case examples, see: http://tsqlt.org/user-guide/tsqlt-tutorial/
ALTER PROCEDURE [DependentTablesTests].[test no rows in SELECT]
AS
BEGIN
IF OBJECT_ID('expected') IS NOT NULL DROP TABLE expected

--Assemble
DECLARE @CID NVARCHAR(50)
SET @CID = '7000'
DECLARE @JID INT
SET @JID = 7000

EXEC tSQLt.FakeTable 'dbo', 'tblJC'

INSERT INTO dbo.tblJC
( JobID ,
ClientID ,
Cost
)
VALUES ( @JID , -- JobID - int
@CID , -- ClientID - nvarchar(50)
0.0 -- Cost - float
)
SELECT
*
INTO expected
FROM
dbo.tblJC

--Act
EXEC dbo.Proc_TESTED_CODE @JID, @CID

--Assert
EXEC tSQLt.AssertEqualsTable @Expected = N'expected', -- nvarchar(max)
@Actual = N'dbo.tblJC', -- nvarchar(max)
@FailMsg = N'Table tblJC actual does not match expected' -- nvarchar(max)


END;
bootieday
 
Posts: 11
Joined: Tue Aug 30, 2005 2:14 pm

Postby David Priddle » Fri Feb 14, 2014 12:30 pm

Hi bootieday,

Unfortunately I can't run your code to reproduce this, as it depends on tblJC and Proc_TESTED_CODE.

Can you confirm that you're using the latest 1.5 beta version of SQL Test?

Best regards,

David
David Priddle
 
Posts: 36
Joined: Tue Jan 28, 2014 10:22 am
Location: Red Gate Software, Cambridge


Return to SQL Test

Who is online

Users browsing this forum: No registered users and 0 guests