Why do SQL Test Messages appear doubled?
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 |
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 |
Comments
I am guessing that AssertEqualsTablewill write its' own failure output so it's not necessary to also write your own failure message.
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
-- 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;
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