Posts

Showing posts from 2020

Automate SQL Stored Procedure Unit Testing for Code First Approach Part - 2

Image
In the last post we have learnt how to create SQL Server Database project and how to create unit test project using that. Also we have learnt how to add unit test case and add pre test and post test scripts.If you have missed anything please follow the below link. Link : https://codespate.blogspot.com/2020/07/automate-sql-stored-procedure-unit.html Today we are going to add the unit test and database project to azure pipeline and automate the build and test.I am following the ef code first approach.So the database deployment will be handled by the migrations/migrator. This sql server project is useless for me. But why we have added that here is to simplify the unit test creation. So the plan is Application and the database will be deployed through the existing pipeline We need to modify the build pipeline to build the sql unit test project After release only we can see the latest changes in the database.So we need to add the testing after the release only. Thus we need to cre...

Automate SQL Stored Procedure Unit Testing for Code First Approach Part -1

Image
Currently I am working on a project that uses ef core and for most of the server side aggregate  operations, I am using stored procedures. Using the stored procedures along with ef core I can able to optimize the performance and reduce the response time. But when it comes to testing, its quite difficult to test the logic of the stored procedure with unit testing.  Application wise we can mock the stored procedure results and unit test the logic.But we cant test the logic inside the stored procedures. Because most of the unit testing frameworks using the in-memory database. So to overcome these, I have decided to use the SQL Server Database Project to the solution. Since I am following the ef code first approach this project will not help me with the database deployment but this will simplify the process of creating the unit test cases for the stored procedures. So I am going to  cover the following in this article to show how I have done the unit testing. Steps to A...

Fix Sql Unit Test build failure in Azure Devops pipeline

Image
Recently I have faced an issue when adding the SQL DB project and SQL Unit test project to my existing .net core solution. In my local machine I am able to build successfully but the build failed in Azure devops pipeline. I got the below error when I build with .net core CLI.  Error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.301\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.301\\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" is correct, and that the file exists on disk. Some of the discussions mentioned that specifying the vs SSDT path will fix the issue. So i have unloaded the project and edited the paths as below. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets But...