How to convert VS2010 SQL Server Unit test project to VS 2012?

259 views Asked by At

I have VS 2010 project with SQL Server unit tests. I need to convert them to VS2012. After much googling I found a msdn article which does not lay out the steps. The context menu on project does not contain anything related to project upgrade. After opening the project in 2012 you wont see your test sql unit test queries. If I open it in vs 2010 I see them. After opening the project in vs 2012 and if I create new sql unit test it will get pop-up box saying :

enter image description here

I have SSDTBI_VS21012 installed. Any idea how I go about converting my VS2010 project with SQL Server unit tests to VS2012?

1

There are 1 answers

5
Kevin Cunnane On

I work on the product team, thanks for raising this. After a quick investigation, this looks like it is a regression introduced in the July release of SQL Server database tooling in Visual Studio. Could you please file a connect bug for this issue at https://connect.microsoft.com/SQLServer/feedback/CreateFeedback.aspx and use the category "Developer Tools(SSDT, BIDS, etc.)". We will treat this as high priority, and this is the best way to ensure it'll get tracked and you can see when it's fixed.

Unfortunately there is no workaround in the July/November releases as an overzealous check was added to avoid showing this option for all unit test projects, and we don't have an overrideable command. However, to unblock yourself you should be able to do one of two things:

Workaround #1 uninstall the database tooling components and install an earlier version instead. Here's how:

  • Go to Add/Remove Programs
  • Uninstall "Microsoft SQL Server Data Tools 2012", which is the overall installer, if present
  • Uninstall "Microsoft SQL Server Data Tools - enu" (if you have English installed).
  • You shouldn't have to uninstall "Microsoft SQL Server Data Tools Build Utilities - enu" if you're using July/November release as it's no longer relevant. However if you run into trouble, consider uninstalling this too.
  • Install the April release of SQL Server tooling for VS2012 instead. The SSDTSetup.exe file to do this is found at http://download.microsoft.com/download/0/D/F/0DF6C816-A7D5-4C17-8B10-2061FC97D37E/EN/SSDTSetup.exe. Note if you are not using English, change the "/EN/" part of the URL to a different language such as DEU and it should allow you to download that language version.

Workaround #2 Migrate to a new Unit Test Project You can alternatively create a new SQL Unit Test Project and migrate your tests across:

  • Create a unit test project based on a procedure in your SQL Project, or create a new Unit Test Project and go to "Add -> New Item -> SQL Server -> SQL Server Unit Test").

  • When it opens the SQL Server Test Configuration dialog, be sure to enter valid values for the reference project and the connection string(s) - these should match your previous project

  • Copy across your unit test files from the old project. If you build, it will fail due to a missing reference. We'll fix that next.

  • Unload the project (right-click, unload project) and add the following snippet near the top:

    <PropertyGroup>
      <IncludeSsdtUnitTestAdapter>True</IncludeSsdtUnitTestAdapter>
    </PropertyGroup>
    
  • Reload the project, and build. This should now pass as the adapter DLL used in migration will be included in the references.

  • Lastly, run the tests and it should work.