I am trying to execute from powershell the Visual Studio's tool MSTest with no success:
$testDLL = "myTest.dll"
$mstestPath = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe"
$arguments = " /testcontainer:" + $testDLL + " /test:UnitTest1"
Invoke-Expression "$mstestPath $arguments"
I get this error: "The term 'x86' is not recognized as the name of a cmdlet, function,..." Any idea? Thanks.
Edit:
Ok, the problem was solved using "&" instead "Invoke-Expression" and creating separated variables for each argument, it doesn't work for me just using both in one var:
$testDLL = "myTest.dll"
$mstestPath = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe"
$argument1 = "/testcontainer:" + $testDLL
$argument2 = "/test:UnitTest1"
& $mstestPath $argument1
I'd recommend using the &
operator in the case (see comment David Brabant).
However, if you must use Invoke-Expression you could convert $mstestPath
to its shortpath equivalent.
$testDLL = "myTest.dll"
$fs = New-Object -ComObject Scripting.FileSystemObject
$f = $fs.GetFile("C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe")
$mstestPath = $f.shortpath
$arguments = " /testcontainer:" + $testDLL + " /test:UnitTest1"
Invoke-Expression "$mstestPath $arguments"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With