This procedure runs single unit tests individually using all available framework functionality. Results of the run will be saved in to the DBTD_TBL_TESTRESULT table and DBTD_TBL_LOG table.

Arguments

  • v_TestName   - Name of the Unit Test stored procedure. VARCHAR(128)
  • v_HasSetup   - "1" if this unit test suite have setup procedure, "0" if there is no setup procedure, or if you do not want to run setup  
  • v_HasTeardown  - "1" if this unit test have teardown procedure, "0" if teardown procedure does not exist or you do not wan tot run teardown
  • v_TestOwner  - Optional reserved parameter
  • v_Ignore - Set to "0" ru run the test or set to "1" to ignore this unit test, this value will alow you to override hint options specified for this test  
  • v_SetupName  - Name of the setup stored procedure
  • v_TeardownName - Name of the teardown stored procedure
  • v_RunSetupOnce  - When value set to "1" then setup procedure assumed to be ran already. Default value is "0"
  • v_RunTeardownOnce - When set to "1" then teardown assumed to be ran already. Default value is "0" 
  • v_UseTransaction - when set to "1" then framework will wrap unit tests (together with setup) into a transaction. It is not necessary to use teardown when using transactions. Default value is "0"
  • v_IgnoreReason  - the reason why this unit test has been ignored, VARCHAR(500), Default value is NULL

 

Transaction support

  • When v_UseTransaction flag is set to 1 test runner will wrap Unit Test into a transaction, and will rollback any changes made by the test after execution. When v_UseTransaction flag is set to 0 (default value) runner will not use transactions. 
  • When transaction is used, test runner does not execute teardown functionality instead it assumes that transaction will clean up all the changes.
  • Using transaction feature can be impacted by user’s code and might interfere with transaction logic codded in your scripts. If you run in to situations like this try to test your code without transaction enforcement until you are satisfied, and then try to turn transactions on again.

 

Examples

SQL Server

 

EXEC DBTD_RUNONETEST_EXT 
    @v_TestName = 'UT_TEST_VerifySomeComplicatedLogic)',
    @v_HasSetup = 1,
    @v_HasTeardown = 0,
    @v_TestOwner = 'dbo',
    @v_Ignore = 0,
    @v_SetupName = 'dbo.sp_mySetUp',
    @v_TeardownName = '',
    @v_RunSetupOnce = 0,
    @v_RunTeardownOnce = 0,
    @v_UseTransaction = 0
 

See Also