我正在尝试运行包含运行负载测试文件的MSTest的批处理文件,但它总是返回错误消息“执行测试需要Visual Studio Enterprise。” Visual Studio 2015 Enterprise已与MSTest一起安装在我的机器中。
以下是批处理文件的内容:
pushd ..
"D:\Visual Studio 14.0\Common7\IDE\MSTest.exe" /testcontainer:%arg1% /testsettings:Local.Testsettings /resultsfile:Scripts\TestResults\%arg2%.trx"
popd
其中:
%arg1% = loadtest.loadtest
%arg2% = loadtest.loadtest.date
Local.Testsettings: x64
答案 0 :(得分:0)
作为answer here的一部分,尝试通过TFS / Powershell运行测试时遇到了同样的问题。为了解决这个问题,我在运行测试之前采用@allen的建议将其称为“ Developer Command Prompt”(开发人员命令提示符),并在Powershell脚本中实现了一个解决方案,它似乎适用于我对其进行测试的两台服务器,我已经对其进行了调整与BAT兼容:
**注意:这是针对VS 2017的,我相信您只需更改路径即可调用以前的版本**
(对于@ user6329531,此修复程序的BAT版本,请在执行测试之前调用此命令)
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
(用于运行Microsoft“ LoadTests”的完整Powershell脚本)
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
}