Unit Test

Unit Test is the stored procedure by which individual units of code or individual requirements can be tested. When creating unit test focus on the smallest testable functionality, chose to create multiple simple tests instead of one complex unit test that that combines different logic. Each unit test should be independent and it should be codded with isolation in mind, one Unit Test should not call another Unit Test directly. If both Unit Tests share common functionality, such functionality should be encapsulated into separate stored procedure to achieve desired flexibility.

Use DBTD_FAILURE or DBTD_ERROR procedures to implement custom assertion logic, to report errors or failures and stop the test execution.

Use DBTD_IGNORE procedure anywhere in the Unit Test DDL for the test to be ignored.

When you want to wrap Unit Test Execution in to a transaction to make sure that database restored to it original state after rest execution add DBTD_USE_TRANSACTION hint anywhere in the Unit Test DDL, in the similar way you can also prevent use of transactions by specifying DBTD_DO_NOT_USE_TRANSACTION hint in the Unit Test.

Naming convention

Before Version 4.0

Unit test should start with "UT_" prefix followed by the <suite name> and ending with the <test name>

UT_<SuiteName>_<testnameA>

UT_<SuiteName>_<testnameB>

Note: There should be only two underscore symbols in the unit test name.

Starting Version 4.0

We have relaxed naming convention rules while supporting legacy pre 4.0 naming convention at the same time.

Now Stored procedure with any name (supported by the database engine identifier) can be used as a Unit Test. To differentiate Unit Test stored procedure you would need to call DBTD_UNIT_TEST hint within that procedure.