I've been experimenting with unit tests in Visual Studio for SQL Server Data Tools (SSDT) projects. I've found an issue in the unit test designer that I have no idea how to debug or resolve.
Background:
In Visual Studio 2019 I created a SSDT project and populated it by importing a database. I found the easiest way to create a separate unit test project capable of running SQL Server tests was to right click on a stored procedure in the SSDT project, and select Create Unit Tests..., then select the option to add the unit test to a new project.
To add a new unit test to the test project I right click the project, select Add > New Item... > SQL Server > Sql Server Unit Test.
The Issue:
I was trying to add a Scalar Value test condition to my first SQL Server Unit Test. When I tried to set the Expected Value in the Properties window an error dialog appeared, saying "Property value is not valid". The detailed message was "Object reference not set to an instance of an object."
I found that trying to set any property in the Properties window resulted in the same error. However, there was no indication of what the object was that was null.
I've been able to work around the problem by setting the property value in the underlying C# class, instead of using the Properties window. If I do that the test runs successfully. So it appears the problem is confined to the test designer.
The issue is not confined to just Scalar Value test conditions. I ran into the same problem with a Row Count condition as well - I couldn't set any property in the Properties window because whenever I did the error dialog prevented me from changing the value.
Has anyone come across a similar issue and found a fix for it?