SSDT Unit Test Connection For Validation. Really?

When you create database unit test project, you need to setup connections to your database. I always use only one connection to run the code and test conditions. But I was curious what is the second connection for? Where does that validation occur?

unit test connections

Now I’ve spent some time to check when this validation connection is really used. I’ve created a simple unit test and placed a simple command to check user name in every part of unit test:

Here are the results of my checks.

Part of the unit test Connection used
Test initialize Connection 2
Pre-test Connection 2
Test execution Connection 1
Post-test Connection 2
Test cleanup Connection 2

As you see, only test execution phase uses connection 1 (“execution”), whereas all the other phases use connection 2 (“validation”) if you use 2 connections. If you use only one connection, so all the steps will be run under this unique username.

It’s a bit strange that SSDT uses a term “validation” for a connection for pre- and post-test steps. But that’s out of our will 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *