52

Does MSTest have standalone GUI similar to nUnit that lets me use it and run test without visual studio? What is the official site for MSTest where I can learn more about how to use it?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
bitbonk
  • 48,890
  • 37
  • 186
  • 278
  • Related post - [Can I use mstest.exe without installing Visual Studio?](https://stackoverflow.com/q/3402899/465053) – RBT Feb 24 '21 at 04:32

7 Answers7

40

MSTest can be used without installing Visual Studio. You will need to install Visual Studio Test Agent, which is a free download from Microsoft.

I think this approach is better from a licensing perspective than manually copying MSTest.exe and its dependencies onto the build server.

See this blog for reference: http://blogs.msdn.com/b/anutthara/archive/2009/12/16/running-tests-in-mstest-without-installing-the-vs-ide.aspx

Josh
  • 2,142
  • 2
  • 23
  • 20
boris
  • 1,525
  • 3
  • 13
  • 18
  • 1
    There are chocolatey packages for both the `visualstudio2013testagents` and `visualstudio2015testagents` which should install to the correct locations for your CI system (TeamCity/Jenkins) or other tools to use. – dragon788 Feb 22 '17 at 20:48
20

It doesn't have a GUI (apart from Visual Studio) but there's a command line tool: MSTest.exe

Here is the official documentation on running MSTest tests.

Alexander Kojevnikov
  • 17,580
  • 5
  • 49
  • 46
  • @mark - but that's a lot of work to get your tests to run on a build server :) – Gishu Feb 10 '11 at 05:48
  • 1
    I have a two parts reply. The first part is that you do it onc and the benefit is that the build server remains clean - no VS installed. The second part is that this was the least significant problem we had with mstest. Other problems - inability to have dynamic and combinatorial tests forced us to abandon mstest and adopt MbUnit/Gallio and we have never regretted that decision. – mark Feb 10 '11 at 11:43
  • @mark - thanks for sharing your war story. Nice info. I have always felt no reason to move from Nunit to mstest.. but the org. powers think otherwise. – Gishu Oct 14 '11 at 11:05
  • @Gishu - You are welcome. I strongly advise you to convince whoever is in charge to use Gallio/MbUnit. It is a much more mature framework than mstest. Plus its VS addin seamlessly integrates with all the standard VS Test windows, so you can still run all the unit tests from within the IDE. Do not repeat our mistakes. – mark Oct 14 '11 at 17:39
  • There's now a [console runner](http://msdn.microsoft.com/en-GB/library/ms182486.aspx). – Roman Feb 07 '14 at 14:09
  • @mark Does your opinion still apply regarding Gallio in 2020? It seems to be rather dead as a project. Site not been updated since ... 2012/2013? (https://github.com/Gallio) – W.Prins May 06 '20 at 11:55
  • @W.Prins - Nope. Gallio is dead, as you noted. I am now using .Net Core with the standard Microsoft.Net.Test.Sdk which with the proper adapter can run xUnit and NUnit and MSTest v2 and that is good enough for me. It does not require VS, only the VS build tools, which is fine. All the dependencies are NuGet packages. So, no problem anymore. – mark May 06 '20 at 13:48
12

You can do this with mstest.exe, but the trick is in getting it to work without installing visual studio. This involves the copying of several files and registry entries. I have blogged about it here.

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
  • 5
    Nice trick ... the complexity of the process is an argument to write tests in NUnit :) – Precipitous Jun 30 '09 at 22:27
  • Thanks, the post is really helpful. You've published the update to that post, which includes batch script to create a 'deployable mstest package', in case someone doesn't notice that on your site, here's the link: http://mindinthewater.blogspot.com/2011/02/executing-visual-studio-2010-unit-tests.html – Nikita R. Feb 15 '12 at 13:06
5

Use Gallio as your test runner... then its not so much of a drama when you enventually drop MsTest and move to a real test framework.

Pat
  • 16,515
  • 15
  • 95
  • 114
RhysC
  • 1,644
  • 1
  • 15
  • 23
  • 3
    Gallio still requires MSTest to be installed separately. This doesn't solve the problem at hand. – alimbada Apr 26 '10 at 11:28
  • 1
    um, yes it does. "Does MSTest have standalone GUI similar to nUnit that lets me use it and run test without visual studio?" I run tests without VS all the time with Gallio. The question is with regard to VS, not MsTest. Running test outside of VS is much faster and leads you to be CI practices – RhysC Apr 27 '10 at 08:52
  • This is an awesome tool. Works just like NUnit UI. – Teoman shipahi Jun 25 '15 at 17:42
5

Use VSTest.console.exe part of Microsoft.TestPlatform

Required steps:

  1. Download the test platform from https://www.nuget.org/packages/Microsoft.TestPlatform/
  2. Unzip
  3. In the unzipped folder, copy the \tools\net451\Common7\IDE\Extensions\TestPlatform folder to the machine that has no Visual Studio installed
  4. From cmd.exe run VSTest.console.exe MyTest.dll

More details here:https://learn.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2017#general-command-line-options

Siraf
  • 1,133
  • 9
  • 24
3

You can also use this tool from codeplex: http://testrunner.codeplex.com...

0

Uset "dotnet test", it is compatible with all versions, eg:

'dotnet test yourassembly.dll -l console -v detailed'
Iván Kollár
  • 39
  • 1
  • 3