Do you unit test your database?
Updated by Anton Polkanov [SSW] 2 years ago. See history
123
We've all heard of writing unit tests for code and business logic, but what happens when that logic is inside SQL server?
With Visual Studio, you can write database unit tests. These are useful for testing out:
- Stored Procedures
- Triggers
- User-defined functions
- Views
These tests can also be added to the same library as your unit, web and load tests.

Figure: Database Unit Test

Figure: Writing the unit test against a stored proc
If you want to know how to setup database unit tests locally and in your build pipeline, check out this article: Unit Test Stored Procedures and Automate Build, Deploy, Test Azure SQL Database Changes with CI/CD Pipelines