This is one of the miscellaneous assert procedures that is used to test framework functionality. This assert procedure will execute an assert procedure that is being tested and will verify that tested assert will fail and report the message into the DBTD_TBL_LOG table. If expected log message is not found this assert will fail.

Arguments

  • v_Test_Name - Name of the unit test that executes this assert, VARCHAR(500)
  • v_Assert_Name – name of the assert procedure that need to be tested, VARCHAR(500)
  • v_SQL - the SQL command that call assert without user message, NVARCHAR(MAX). The user message will be generated automatically to ensure uniqueness across all records in the log  
  • v_Verbose - Default value is NULL, when value set to 1 procedure will return a select statement that will pull all relevant log records for troubleshooting purposes. SMALLINT

 

Examples

SQL Server  

USE DBTestDriven
GO

--***********************************************************************
EXEC DBTD_DROP_PROC_IF_EXISTS 'UT_DBTD_AssertColumnHaveValue'
GO

--***********************************************************************
CREATE PROCEDURE UT_DBTD_AssertColumnHaveValue
AS
BEGIN
    EXEC DBTD_UNIT_TEST 'DBTD';
    DECLARE @v_SQL VARCHAR(500);
    DECLARE @v_Test_Name NVARCHAR(128) = OBJECT_NAME(@@PROCID);
    DECLARE @v_Assert_Name VARCHAR(50) = 'DBTD_ASSERT_COLUMN_HAVE_VALUE';

    --check that assert fails correctly when valie not found
    SET @v_SQL = 'EXEC '+ @v_Assert_Name
           + ' ''DBTD_tmp_UniqueNotUnique'', ''ColUnique'','
           + ' ''QWERTY'', ''VARCHAR(50)'',  ';
    EXEC DBTD_ASSERT_FoundUniqueMessage @v_Test_Name, @v_Assert_Name, @v_SQL;

    --check that assert succeeds when valie is found
    SET @v_SQL = 'EXEC '+ @v_Assert_Name
           +' ''DBTD_tmp_UniqueNotUnique'', ''ColNotUnique'', ''1'', ''INT'',  ';
    EXEC DBTD_ASSERT_NOTFoundUniqueMessage @v_Test_Name, @v_Assert_Name, @v_SQL;

    --check that assert fails correctly when value of the incorrect type
    SET @v_SQL = 'EXEC '+ @v_Assert_Name
           +' ''DBTD_tmp_UniqueNotUnique'', ''ColUnique'', ''QWERTY'', ''INT'',  ';
    EXEC DBTD_ASSERT_FoundUniqueMessage @v_Test_Name, @v_Assert_Name, @v_SQL;

END;
GO

 

See Also