Forum Discussion
AravindS2190
May 22, 2020Copper Contributor
SQL Server Unit Test Project using Visual Studio
Hello All, I have created SQL Unit Test project using the built-in Visual Studio Test project. I am able to create test cases for all scenarios using Pre-Test, Test and Post-Test conditions. Also, I...
bake13
Microsoft
May 23, 2020Hi AravindS2190 -- What error are you receiving when attempt to drop the database?
AravindS2190
May 23, 2020Copper Contributor
Hello bake13 - I am not receiving any errors. Whereas I am looking for options how to do.
But I have finally found a way to do it.
I have used [AssemblyCleanup] attribute to drop my database post completion of all the tests. This [AssemblyCleanup] will be executed once per assembly and this is what I was looking for.
[AssemblyCleanup]
public static void MyCleanup()
{
//Your test code goes here
// Read from config file
// Drop your database
}
Now with my SQL Unit Test, I can create database in any local server using DACPAC, Unit test them and finally drop them as well.
Thanks