1

I've configured the Jenkins MSTestRunner plugin to use the following path to the MSTest executable: 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe'. However, although this path is correct, the build fails as follows:

cmd.exe /C "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe" "/resultsfile:/resultsfile testresults" /testcontainer:Project.Tests/bin/Debug/Project.Tests.dll && exit %%ERRORLEVEL%%
'C:\Program' is not recognized as an internal or external command, operable program or batch file.

What's the issue here, I thought this would be the normal way of configuring the MSTestRunner plugin as mstest.exe is installed beneath Visual Studio, which is again typically installed under 'C:\Program Files (X86)'? How do I work around this?

aknuds1
  • 65,625
  • 67
  • 195
  • 317
  • 1
    As the error message states, path parsing is stopping at the space and the rest of the path is taken as a argument here. So the command environment is literally trying to execute "Program" located at C:\. I am guessing this would work if you enclose the path with double quotes("). – CIGuy Sep 04 '12 at 15:21
  • I don't know if this is an option for you, but could you add "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE" to your Path environment variable on that machine and then just specify mstest.exe in the Jenkins configuration? – CIGuy Sep 04 '12 at 17:56
  • Note that the above approach will require a restart of Jenkins after adding the Path variable in order for Jenkins command environment to pick it up. – CIGuy Sep 04 '12 at 17:58
  • @CIGuy Yeah I figured that'd be the last resort, but I'm not very eager :/ I suppose maybe I could just write a commandline build step directly, sidestepping the problematic plugin altogether. – aknuds1 Sep 04 '12 at 18:38

2 Answers2

4

Have received confirmation from the plugin author that MSTestRunner 0.2.0 doesn't handle spaces in MSTest paths. I worked around the issue by instead creating an "Execute Windows batch command" build step in Jenkins that invokes mstest.exe directly, where I've surrounded the mstest.exe path with double quotes:

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:Project.Tests\bin\Debug\Project.Tests.dll /resultsfile:testresults.trx
aknuds1
  • 65,625
  • 67
  • 195
  • 317
1

Found that my issue was 2 fold.

  1. File entries are from local workspace dir
  2. You must configure mstest in global tools and then select that instance within the build step.
Kentonbmax
  • 938
  • 1
  • 10
  • 16