Unit testing has been a common and accepted practice in application development for a long time. By testing certain functions and areas – or units – of code, it verifies those functions work as expected, and improves the quality of code.
tSQLt brings the same advantages to SQL Server database development, and is compatible with all editions of SQL Server from the 2005 Service Pack 2 edition onwards.
Importantly, because tSQLt allows you to implement unit tests in T-SQL, you don’t have to switch between various tools to create the code and unit tests. tSQLt also provides the following features to make it easier to create and manage unit tests:
- Tests are automatically run within transactions – this keeps tests independent and reduces any cleanup work
- Tests can be grouped together within a schema – allowing you to organize your tests and use common setup methods
- Output can be generated in plain text or XML – making it easier to integrate with a continuous integration tool
- The framework gives you the ability to fake tables and views, and create stored procedure spies – allowing you to isolate the code being tested
Even if you have a large code base and no existing unit tests, you can start introducing tests now to make your database code more robust to change.
So download the latest version of tSQLt, read the Full User Guide or follow our Quick Start guide if you’re in a hurry. And, if you want to make the most of tSQLt, browse through our library of articles.