Do you unit test your database?

Updated by Anton Polkanov [SSW] 2 years ago. See history

123
<introEmbed body={<> 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. </>} />
Image

Figure: Database Unit Test

Image

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

Acknowledgements

Adam Cogan
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star