Working with tests
Published 04 February 2013
SQL Test runs tests depending on what is selected in the SQL Test interface.
Running all tests for a database
To run all the tests for a database, make sure the database is selected in the SQL Test interface, and click :
To run tests for all databases in SQL Test, press Alt + Shift + X.
Running a test class
To run a group of tests in a test class, make sure the test class you want to run is selected, and click :
Running a single test
To run a single test, make sure the test you want to run is selected in the SQL Test interface, and click .
Alternatively, right-click the test, and click Run Test:
Test status indicators
In the SQL Test list, the icon before the test name displays the status of the test:
There is no result for this test. Either this is a new test you've created, or a test you haven't run since you launched SQL Test. | |
When the test was last run, it passed. | |
When the test was last run, it failed. |
Editing a test
To script out a test as an ALTER PROCEDURE query, double-click the test in the SQL Test tab.
Alternatively, you can right-click a test in the SQL Test tab, and click Edit Test.
For information about writing tests in T-SQL using the tSQLt framework, see tSQLt User Guide.
Renaming a test or test class
To rename a test or test class:
- In the SQL Test tab, select the test or class you want to rename, and press F2.
- Type a new name, and press Enter.
Deleting a test
To delete a test from the database:
- in the SQL Test tab, select a test, and press the Delete key.
Alternatively, you can right-click a test in the SQL Test window, and click Delete Test:
- On the confirmation dialog box, click Yes.
Tests are stored procedures, so deleting a test will drop the stored procedure from your database.