Where is the Microsoft.VisualStudio.TestTools.UnitTesting namespace on VS2010?
Asked Answered
A

6

45

I converted a VS2008 solution that contains some unit testing projects to VS2010. After the conversion I tried to compile the solution, but I'm getting the following error:

The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

The namespace declaration cannot be found using Microsoft.VisualStudio.TestTools.UnitTesting;. In addition, I couldn't find the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly when I tried to add a new project reference.

Does anyone know what I'm doing wrong?

Acquisition answered 20/7, 2010 at 18:55 Comment(1)
Anyone know if it's on Nuget?Zwickau
J
22

I just had this problem as well, and with a Microsoft.Data.Schema library as well. The answer is correct, in that these library are on the machine and in the VS 10.0 directory.

The problem (at least for me) was that the solution was converted from VS2008 and the conversion utility targetted the project for .NET 3.5. Since the 10.0 library require .NET 4.0 they are not picked up by the compiler.

The solution is to either revert to use VS2008 where these resolve correctly; or to switch the project to compile for .NET 4.0 so you can use the available libraries.

Jobi answered 10/8, 2010 at 2:19 Comment(3)
I've fixed the problem doing the same. +1 for the answer.Acquisition
just wanted to add a note for anyone else finding this answer as a result of a similar problem - try restarting Visual Studio, sometimes it's just got muddled.Melvinmelvina
Also make sure that "Specific version" is set to False, otherwise the .NET 4.0 dll's will not get picked up.Ridgepole
O
71

It's called Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.

You can find it in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.

Orbicular answered 20/7, 2010 at 19:0 Comment(2)
Thanks SLaks! That was correct. I had downloaded the SQLConfigurationSource project from Codeplex and tried to compile it . It failed because MS forgot to update their Documentation (AGAIN) with the new Library. Kudos!!Northumbria
also: c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dllSleek
J
22

I just had this problem as well, and with a Microsoft.Data.Schema library as well. The answer is correct, in that these library are on the machine and in the VS 10.0 directory.

The problem (at least for me) was that the solution was converted from VS2008 and the conversion utility targetted the project for .NET 3.5. Since the 10.0 library require .NET 4.0 they are not picked up by the compiler.

The solution is to either revert to use VS2008 where these resolve correctly; or to switch the project to compile for .NET 4.0 so you can use the available libraries.

Jobi answered 10/8, 2010 at 2:19 Comment(3)
I've fixed the problem doing the same. +1 for the answer.Acquisition
just wanted to add a note for anyone else finding this answer as a result of a similar problem - try restarting Visual Studio, sometimes it's just got muddled.Melvinmelvina
Also make sure that "Specific version" is set to False, otherwise the .NET 4.0 dll's will not get picked up.Ridgepole
S
6

For Visual Studio 2015 Users:

Had similar problem, but with upgrading a Prism WPF application StockTraderRI Unity version from Prism 2.2 to 5.0 using Visual Studio 2015. The 5.0 version used MEF and I needed the Unity version.

The steps I did was:

  1. Delete the assembly reference

enter image description here

  1. Add it back

enter image description here

  1. by selecting Assemblies | Extensions

enter image description here

  1. In the search box enter Microsoft.VisualStudio.QualityTools.UnitTestFramework

enter image description here

I had to do this for several test projects and the fastest way to repeat the adding is to just select Assemblies | Recent

enter image description here

Superimpose answered 3/9, 2015 at 21:5 Comment(0)
I
4

For VSTS 2010, make sure that you have these in the references:

  • Microsoft.VisualStudio.QualityTools.UnitTestFramework

  • Microsoft.VisualStudio.QualityTools.WebTestFramework (if you are doing web testing)

Impressible answered 27/11, 2011 at 4:36 Comment(0)
T
0

Please go and download visual studio 2010 SP1. Install it. It will then allow you to change the frame work of testing project from previously default 4.0 to 3.5 and others. Just change the frame work to the frame work version of the project you want to test. Now the code will combine peacefully and you will be able to run the test.

Thorpe answered 20/7, 2010 at 18:55 Comment(1)
I get the feeling that Syed never tried his suggestion. It is impossible to convert the Target Framework of a Test project from 4.0 to 3.5 in Visual Studio 2010 SP1 without a significant hack. You literally have to trick VS into thinking that it is not a Test project, change the target framework and then change the project back to being a Test project. See here: [unable-to-change-target-framework-version-to-3-5-because-visual-studio-thinks-it-is-a-test-project](connect.microsoft.com/VisualStudio/feedback/details/553106/…Dartmouth
F
0

+Erik Brown is right, the problem is that VS2010 supports targeting your project to .NET 3.5 but doesn't support unit tests in a .NET 3.5 project.

However, since it makes sense to test your code under a framework that your code will be running on in production it is desirable to make this work. One easy way to make this work is to use NUnit instead and use Resharper to run the tests from within Visual Studio or the NUNit test runner. NUnit works with .NET v2.x - v4.x with a single set of binaries.

Fungoid answered 18/10, 2011 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.