Reputation: 99478
I am learning how to use unit test offered by Microsoft.VisualStudio.TestTools.UnitTesting
.
However the tutorials I found are all how to create unit test in Visual Studio IDE. I am not familiar with Visual Studio IDE yet, and think that it distracts me away from understanding how to create and use Microsoft.VisualStudio.TestTools.UnitTesting
.
So
can I add a unit test for a program using Microsoft.VisualStudio.TestTools.UnitTesting
, but without the aid of Visual Studio?
Can I then run the unit test, outside Visual Studio IDE?
Thanks.
Upvotes: 1
Views: 203
Reputation: 38087
Microsoft.VisualStudio.TestTools.UnitTesting
provides attributes you can use on your classes and methods to indicate they are tests.
You could simply create a class library and add a reference to Microsoft.VisualStudio.TestTools.UnitTesting
and your code to be tested. On each class that is a test container, you add the TestClass
attribute and every method within that class that is a test, you would add the TestMethod
attribute.
Compile that DLL and you can execute the tests from the command line using vstest.console.exe
, which is usually located at "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\ide\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
. The command line parameters for vstest.consol.exe are well documented.
Upvotes: 4