Reputation: 13679
I am running MSTest against our test assembly from the command line:
mstest /testcontainer:C:\dev\UnitTests\bin\Debug\UnitTests.dll
This works fine, except I do not want the artifacts from this run to remain. Seems that MSTest leaves a copy around. For me, they're in the C:\dev\TestResults\
directory.
I have investigated a few things:
.testsettings
file. Couldn't find anything there..testsettings
file. This would work, but how can I find the output location MSTest uses for the artifacts?mstest.exe
- and it wouldn't work anyway, as I want to script this for other developers on our team.How can I remove test run artifacts after the run is completed?
Edit: also, I would accept an answer that will run our MSTest tests using an open source test running tool. I just want to script this, man.
Upvotes: 4
Views: 2242
Reputation: 13679
MSTest creates the TestResults directory in $pwd.
function global:runtests()
{
$mstest = Join-Path $env:VS100COMNTOOLS "..\IDE\mstest.exe" -Resolve
$resultsDir = Join-Path $pwd "TestResults"
$testDll = Join-Path $solutionScriptsContainer "..\UnitTests\bin\Debug\UnitTests.dll" -Resolve
$output = & $mstest /testcontainer:$testDll
$o = [regex]::match($output, "^.*(Summary.*)Results file.*$")
$mstflag = "MSTest:"
$op = $mstflag += $o.groups[1].value
Write-Host $op
Write-Host "Deleting $resultsDir"
remove-item $resultsDir -force -recurse
}
Upvotes: 1