1
   Microsoft.VisualStudio.TestTools.UnitTesting

I need to be able to unit test a class that I am building. I tried to add this class through References and it is not in the list of .NET classes.

enter image description here

I do not see this in the list that can be referenced into a project.

How can I Unit Test my class without this reference?

Mantosh Kumar
  • 5,659
  • 3
  • 24
  • 48
Doug Hauf
  • 3,025
  • 8
  • 46
  • 70
  • 1
    possible duplicate of [Where is the Microsoft.VisualStudio.TestTools.UnitTesting namespace on VS2010?](http://stackoverflow.com/questions/3293317/where-is-the-microsoft-visualstudio-testtools-unittesting-namespace-on-vs2010) – ClickRick Apr 23 '14 at 18:31

1 Answers1

4

You need to add a reference to the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly.

Microsoft.VisualStudio.TestTools.UnitTesting is the name of a namespace inside the assembly, not the name of the assembly itself. If you look at the Assert class for example, you can see the assembly it is contained in.

Lee
  • 142,018
  • 20
  • 234
  • 287
  • I do not see that in my references list? – Doug Hauf Apr 23 '14 at 18:40
  • @DougHauf Have you not just added a new Unit Test project to your solution (that will already have the references for you)? – Martin Costello Apr 23 '14 at 18:43
  • @DougHauf - Does [this question](http://stackoverflow.com/questions/3293317/where-is-the-microsoft-visualstudio-testtools-unittesting-namespace-on-vs2010) apply? I don't have VS2010 so I can't try it but if you're targeting .Net 3.5 you might have to add the reference through the file system instead. – Lee Apr 23 '14 at 18:46
  • Is this the only way to have to download a tool. Is there a built in one. The only reason that I ask is because at work I do not have the password to download files onto the system. – Doug Hauf Apr 23 '14 at 19:09
  • @DougHauf - The answers in that question suggest it should be in the VS install directory at `C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll` – Lee Apr 23 '14 at 19:20
  • Ok, I will have to see if I can get permission to download some files. – Doug Hauf Apr 23 '14 at 19:55