Checks that pretend object DOES NOT exists in the database, verifies that pretend object was not automatically created by the DBTestDriven Framework. Report failure in any other case.

Arguments

  • v_PretendObjectName – Name of the stub object. Supports four part object name. SYSNAME data type.
  • v_UserMessage – Message to report when assertion fails, NVARCHAR(MAX)

 

Note: If you are planning to run unit test manually, you must use DBTD_UNIT_TEST hint procedure to explicitly define a unit test procedure as the unit test.

Examples

SQL Server

 

/*Create original business logic*/

CREATE PROC Add_Client

       @Client_Name VARCHAR(100) = 'The Best Client'

AS

BEGIN

       DECLARE @Now DATETIME = GETDATE()

       PRINT 'I am an original business logic';

END

GO

 

/*Create the unit test*/

CREATE PROC UT_SAMPLES_StubForAddClientProcB

AS

BEGIN

       EXEC DBTD_UNIT_TEST 'SAMPLES'

       DECLARE @v_ProcName VARCHAR(128) = 'Add_Client_ForTestProject',

       EXEC DBTD_ASSERT_STUB_NOT_EXISTS

              @v_PrependObjectName = @v_ProcName,

              @v_UserMessage = 'This procedure should not be a stub procedure'   

END

GO

 

--run just one unit test alone to verify results

--note that we will explicitly use transactions

--because we run unit test outside of the DBTestDriven framework

BEGIN TRAN

EXEC UT_SAMPLES_StubForAddClientProcB

ROLLBACK

GO

 

See Also