Question

I'm new to C#, .NET and VS; using VS 2013 Ultimate. I'm trying to create a unit test using what seems to be the "VS way" but can't figure it out.

It looks like the culprit is that I don't have access to the Microsoft.VisualStudio.TestTools.UnitTesting.Assert method or enclosing namespace... I've looked all around and can't find any references to this namespace. Is this something extra I need to install? At this point I have no idea what to look for.

I'm working around it with additional Main methods, which is a huge PITA...

Was it helpful?

Solution

welcome to .NET development!

By default, Visual Studio will add references to the most common namespaces/classes to your project when the project is created. TestTools.UnitTesting is not one of those namespaces, so you'll have to add a reference to the file where it lives, which is in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.

Check out this thread for how to add references (I think your question duplicates it):

OTHER TIPS

You need a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll in your project. It's installed with VS so you should have it listed in the Add Reference dialog. But the correct way would be to create project from "Unit Test" template that will add the reference in advance.

For VS2013, add reference to

Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

from

C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top