Unit Test for SQL Server is based on a free and open source tSQLt framework, which allows creating and running unit tests in T-SQL.
With the tSQLt framework, you can benefit from the following:
You can write SQL unit tests directly in SQL Server Management Studio.
The guide describes the following:
Before you create unit tests, you need to install the tSQLt framework. To do that, in Object Explorer, right-click the required database and select Unit Test > Install Test Framework. In the Install Test Framework wizard that opens, choose the database for which the framework will be installed and click Install. Alternatively, you can initiate the tSQL framework installation from the Unit Test > Install Test Framework menu. For more information about the tSQLt framework installation, see How to install the tSQLt framework.
On the Unit Test menu, click Add New Test. In the Add new test dialog that opens, do the following and then click Add Test:
Then, the progress window will display that the operation has been complete, and you can click Finish to close the wizard. For more information, see Creating new SQL unit tests through tSQLt.
After the test has been created, a new SSMS document opens with a query template to manage the test, where you can write T-SQL code for your test. The template is divided into three blocks:
dbForge Unit Test provides a list of predefined test samples so that you can quickly start working with unit tests.
On the Unit Test menu, click Install Sample Database. In the Install Sample Database dialog that opens, choose the connection on which you want to install the database, enter the database name, and click Install.
When the installation is complete, click Finish to close the dialog. The database will be displayed in Object Explorer. For more information, see Installing and running the example tests.
dbForge Unit Test provides a built-in Test List Manager to view and manage unit tests visually:
To open the Test List Manager, on the Unit Test menu, select View Test List. For more information about how to manage tests, see Viewing test list.
In dbForge Unit Test, you can run all tests either from Object Explorer or Test List Manager. In the latter, you can also run the selected unit tests or those having check marks next to them.
The Test Results grid displays all running tests either with the Succeeded or Failed statuses. For any failed tests, you can view an error message that displays the expected and actual results.
At the bottom of the results grid, you can view the total amount of passed, failed, or checked unit tests. For more information, see Running SQL database unit tests.