1

I am trying to run a batch file that contains the MSTest running a load test file but it always returns an error message of "Visual Studio Enterprise is required to execute the test." Visual Studio 2015 Enterprise is already installed in my machine together with MSTest.

Here are the contents of the batch file:

pushd ..
"D:\Visual Studio 14.0\Common7\IDE\MSTest.exe" /testcontainer:%arg1% /testsettings:Local.Testsettings /resultsfile:Scripts\TestResults\%arg2%.trx"
popd

Where:

%arg1% = loadtest.loadtest

%arg2% = loadtest.loadtest.date

Local.Testsettings: x64

  • Some parts of Visual Studio only install into or work from the system drive which is normally `C:`. Your batch file runs `D:...MStest.exe`. Do you have multiple Visual Studio versions installed and any of them on non-system drives? – AdrianHHH Sep 09 '16 at 10:37
  • run your batch file from the developer command prompt – allen Sep 21 '16 at 14:11

1 Answers1

0

As part of my answer here I had the same issue when trying to run my tests through TFS/Powershell. To fix it, I took @allen's advise to call the "Developer Command Prompt" before running the tests and implemented a solution in a Powershell script, seems to work for the two servers I've tested it on, I've adapted it to be BAT compatible:

**Note: This is for VS 2017, I believe you simply change the year in the path to invoke a previous version*

(For @user6329531, BAT version of the fix, call this before you execute the tests)

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"

(My full Powershell script for running Microsoft "LoadTests")

param (
    [string]$path = ""
 )

#For this to work correctly you need to make sure the following things are done: 
#https://stackoverflow.com/a/53211350/2912011
Write-Output $path

#Start deveng, for some reason it likes to complain if it's not runnning
#https://social.msdn.microsoft.com/Forums/vstudio/en-US/1d5574c0-4a56-4dd1-b390-3a3683278d16/loadtest-require-visual-studio-enterprise?forum=vstest
Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe"

#Run the "Developer Command Prompt" 
cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\"
./VsDevCmd.bat

#Navigate to the MSTest directory
cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\"

#Iterate through the entire directory, run each loadtest one at a time
$fullPath = $path

Get-ChildItem $fullPath -Filter *.loadtest | 
Foreach-Object {
    $content = $_.FullName

    Write-Output $content

    ./mstest.exe /testcontainer:"$content" /detail:testtype
}

try {
    Get-Process devenv -IncludeUserName | Where UserName -match EBMTFSServiceAccount| Stop-Process
}
catch {
    #This may fail, if so it probably is not an issue, but we need to double check...
    Write-Output $_.Exception.Message
}
David Rogers
  • 2,601
  • 4
  • 39
  • 84