75

I need to run mstest from the command line - where in the world is this exe located? Can anyone give me a clue?

Edit: I only have Visual Studio 2010 installed

George Mauer
  • 117,483
  • 131
  • 382
  • 612
  • For VS 2017, I found it at - `C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE` – RBT Mar 03 '21 at 05:22

9 Answers9

92
for %x in (mstest.exe) do @echo.%~dp$PATH:x

from the Visual Studio Command Prompt is your friend. For me it's in

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\
Joey
  • 344,408
  • 85
  • 689
  • 683
  • 17
    that is some crazy batch script-fu – George Mauer Mar 03 '10 at 22:34
  • 2
    Not really; crazy is the stuff that isn't directly documented. This is fairly standard, just see `help for`. – Joey Mar 03 '10 at 22:35
  • 1
    @Joey would you mind breaking down what each port of the batch script does? – Mauricio Aviles Nov 30 '12 at 01:40
  • 1
    It just says "Print me the first path where `mstest.exe` is in my `PATH` environment variable. See `help for` for details. The `for` is necessary as that syntax only works with `for` variables and numbered arguments and apart from that it's straight from the docs. – Joey Nov 30 '12 at 13:23
  • 2
    Guys I suggest to use %VS90COMNTOOLS% path variable – Ilia P Feb 17 '16 at 07:29
  • Just to keep us on our toes MS has not put the common tools under a "15.0" folder for VS 2017 and instead seems to have put it under a "2017" folder. For example: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE – bytedev Sep 04 '18 at 15:45
50

Type

where mstest.exe

into a Visual Studio Command Prompt...

Loofer
  • 6,841
  • 9
  • 61
  • 102
  • 1
    Although @Joey approach is quite clever, I like this simpler way. Besides it gives you the full path (including file name), for me it is `C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe` – Mauricio Quintana Mar 07 '14 at 17:08
  • Most common solution! – Anton K Apr 10 '14 at 23:53
  • If you have no such Visual Studio Command Prompt shortcut, pin it to start after finding it in “C:Program Files (x86)Microsoft Visual Studio 12.0Common7ToolsShortcuts”; http://www.codewrecks.com/blog/index.php/2014/01/31/missing-developer-command-prompt-for-visual-studio-2013/ – AnneTheAgile Dec 08 '14 at 21:58
11

Since Visual Studio 2012 (at least the express versions) MsTest.exe is called vstest.console.exe and can be found at

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe

dwonisch
  • 5,595
  • 2
  • 30
  • 43
10

I stumbled across this post because I'm trying to automate some web tests.

You can run >mstest /TestContainer:some.webtest from the visual studio command prompt, sure - but when you slap that in a batch file the command prompt that's executed by default doesn't have the visual studio tools included.

You can search for mstest.exe, but that location might not be the same across machine, so it's unwise to hardcode in c:\

Rany Miller's answer was god's send to me (thanks!) - he suggested %VS90COMNTOOLS%\..\IDE\MSTest.exe

But that doesn't work if you have VS 2010. Just replace the 90 with 100. My batch file, that I can schedule as a task to run nightly, looks like this:

SET SOURCEe=c:\myTestProjectFolder\
CD %SOURCE%
"%VS100COMNTOOLS%..\IDE\mstest.exe" /TestContainer:some.webtest
mklement0
  • 382,024
  • 64
  • 607
  • 775
Dave Kennedy
  • 480
  • 4
  • 13
6

If you can't find it, try searching like this:

%VS90COMNTOOLS%\..\IDE\MSTest.exe
mklement0
  • 382,024
  • 64
  • 607
  • 775
Randy Minder
  • 47,200
  • 49
  • 204
  • 358
3

My automated test scripts uses:

"%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"  

The full command I use is:

"%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"  /testcontainer:[PathToTestDll] /resultsfile:[TrxOutputPath]
Alan Jackson
  • 6,361
  • 2
  • 31
  • 32
2

If you run a visual studio commmand prompt before you run your scripts -- which should be doable in most situations -- you can run %VSINSTALLDIR\Common7\IDE\mstest -- this means that you can move with the version of VS, and not have to react to director changes if users install in a different directory.

Dominic Hopton
  • 7,262
  • 1
  • 22
  • 29
1
"%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\IDE
Asad
  • 21,468
  • 17
  • 69
  • 94
-1

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

If people only knew that Windows can search for files...

You can simply open up Visual Studio's command line prompt to include that directory in the PATH. Take a look at the start menu entry "Visual Studio 2008 Command Prompt".

AndiDog
  • 68,631
  • 21
  • 159
  • 205
  • It is not there for me. Of course I only have VS 2010 installed...It's not under Microsoft Visual Studio 10.0 either. – George Mauer Mar 03 '10 at 22:31
  • @George Mauer: I don't about VS 2010, but you could simply run a search for the file. And I'm sure mstest is still available in VS 2010's command line prompt. – AndiDog Mar 03 '10 at 22:34