The following tSQLt test checks that a view is not empty. This test is primarily used to check the views that expose data to the end users of data warehouse.
For performance purposes, this test uses TOP 1 when querying the actual view.
CREATE PROCEDURE testFacts.[test that ViewName is not empty]
AS
BEGIN
IF OBJECT_ID('testViewName') IS NOT NULL
BEGIN
DROP TABLE testViewName;
END
-- Update DatabaseName, SchemaName & ViewName to the appropriate names for the object that is to be tested
SELECT TOP 1 Id INTO testViewName
FROM DatabaseName.SchemaName.ViewName;
EXEC tSQLt.AssertNonEmptyTable 'testViewName';
END
See Misusing tSQLt for more info.
One Comment
[…] Misusing tSQLt: test that view is not empty […]