tSQLt is the open source framework for unit testing on SQL Server
This project is maintained by tSQLt-org
This section describes how test cases are created and executed.
We’re going to answer two important questions in this section, “What happens when you create a test class?” and “What happens when a test class gets executed?”
Not much. When you create a test class using tSQLt.NewTestClass, a schema is created. That schema is created with an extended property so that tSQLt can later figure out which schemas are test classes. Note: If there is already a schema with the same name as the one you are trying to create, it is dropped first.
If you execute tSQLt.RunTestClass, tSQLt does the following things:
If you execute tSQLt.RunAll, tSQLt first looks at all the schemas in the database for ones marked as test classes. Then, it follows steps 1 and 2 above for each test class. The test results are displayed after running all test classes.
Create test classes using tSQLt.NewTestClass. Execute test classes using tSQLt.RunTestClass or tSQLt.RunAll. When individual test cases are executed, they are wrapped in a transaction which is rolled-back. Before each test case, SetUp is called if it exists on the test class.