My vstest powershell script is not exiting out of the step

I am trying to run the VSTEST thru powershell script, the steps start really good and once the Test fails. it doesn’t exit out from that step.

here is the script that i am using…

Write-Output “Running xUnit tests with dotnet and vstest…”
$dotNetVer = dotnet --version
Write-Output “DotNet version: $dotNetVer”
$dirPath = “C:\Octopus\Applications\Dev\automation\3.2.0.1_3”
#$dirPath = $PackageDirectoryPath
Write-Output $dirPath
$testFiles = “Automation.dll”
Write-Output $testFiles
$testFilter = “TestCategory=Regression”
Write-Output $testFilter
$xUnitAdditionalParams = $XUnitAdditionalParameters
cd $dirPath
cd …
$TestAdapterPathFile=pwd
Write-Output $TestAdapterPathFile

If(-Not $dirPath){
Write-Output “Directory with tests is missing!”
exit 1
}

If(-Not $testFiles){
Write-Output “Test Package(s) missing!”
exit 1
}

Write-Output “Execute test package(s): $testFiles”
Write-Output “With following filter(s): $testFilter”
Write-Output “From Package Directory: $dirPath”

cd “$dirPath\TestPlatform”
dir

If($testFilter){
$runxUnit = “dotnet vstest ‘$dirPath$testFiles’ /testcasefilter:’$testFilter’ /logger:‘trx’ /TestAdapterPath:’$TestAdapterPathFile’”
Write-Output “Run xUnit with filter $testFilter”
#Write-Output “Run xUnit with filter $runxUnit”
} Else {
$runxUnit = “.\vstest.console.exe ‘$dirPath$testFiles’ /logger:‘trx’ /TestAdapterPath:’$TestAdapterPathFile’”
}

if($xUnitAdditionalParams){
$runxUnit = $runxUnit + " " + $xUnitAdditionalParams
Write-Output “Run xUnit with Additional Params $xUnitAdditionalParams”
}

Write-Output “Run xUnit with command: $runxUnit”

iex $runxUnit

$xunitExit = $lastExitCode

Write-Output “==="
Write-Output "
===”
Write-Output $xunitExit
exit $lastExitCode
exit

Octopus job stuck in there for almost 11hrs

Hi @mahfooz

Thanks for reaching out! As this is your script and not something that I can replicate/test against I’m not sure how useful I can be.

All I can suggest at this point is to have a look in your Octopus logs and check to see what the last printed message was as that should give you an indication of where your script is failing. We also have a documentation page on Powershell debugging that should also provide some useful information.

Hopefully that helps,

Regards,
Alex

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.