AnneTheAgile
10 years agoContributor
cannot capture return code from command line in powershell OR batch
I have two trivial tests. zTdd1_Good provides green, passing. zTdd2_Fail provides a very simple red, failure. They both appear to work great, with the small exception that the script at the end of 2_Fail doesn't run due to failing earlier.
I want to capture the return code from the test, ie zero for good and non-zero for failure.
The docs say this should work and in fact point to a list of supported return codes. How can I get this to work?
I want it to work the most in powershell, which is more robust. Since it doesn't work in batch either, it seems like something is grossly wrong?
thank you!
code; in powershell ISE as administrator;
PS C:\windows\system32> & "c:\Program Files (x86)\SmartBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestComplete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestProject1 /test:"KeywordTests|zTdd1_Good" /exit
PS C:\windows\system32> echo $LASTEXITCODE
0
PS C:\windows\system32> & "c:\Program Files (x86)\SmartBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestComplete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestProject1 /test:"KeywordTests|zTdd2_Fail" /exit
PS C:\windows\system32> echo $LASTEXITCODE
0
code, in Batch VS2013 prompt;
C:\Program Files (x86)\Microsoft Visual Studio 12.0>"c:\Program Files (x86)\Smar
tBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestCompl
ete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestPro
ject1 /test:"KeywordTests|zTdd1_Good" /exit
C:\Program Files (x86)\Microsoft Visual Studio 12.0>echo %ERRORLEVEL%
0
C:\Program Files (x86)\Microsoft Visual Studio 12.0>"c:\Program Files (x86)\Smar
tBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestCompl
ete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestPro
ject1 /test:"KeywordTests|zTdd2_Fail" /exit
C:\Program Files (x86)\Microsoft Visual Studio 12.0>echo %ERRORLEVEL%
0
I want to capture the return code from the test, ie zero for good and non-zero for failure.
The docs say this should work and in fact point to a list of supported return codes. How can I get this to work?
I want it to work the most in powershell, which is more robust. Since it doesn't work in batch either, it seems like something is grossly wrong?
thank you!
code; in powershell ISE as administrator;
PS C:\windows\system32> & "c:\Program Files (x86)\SmartBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestComplete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestProject1 /test:"KeywordTests|zTdd1_Good" /exit
PS C:\windows\system32> echo $LASTEXITCODE
0
PS C:\windows\system32> & "c:\Program Files (x86)\SmartBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestComplete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestProject1 /test:"KeywordTests|zTdd2_Fail" /exit
PS C:\windows\system32> echo $LASTEXITCODE
0
code, in Batch VS2013 prompt;
C:\Program Files (x86)\Microsoft Visual Studio 12.0>"c:\Program Files (x86)\Smar
tBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestCompl
ete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestPro
ject1 /test:"KeywordTests|zTdd1_Good" /exit
C:\Program Files (x86)\Microsoft Visual Studio 12.0>echo %ERRORLEVEL%
0
C:\Program Files (x86)\Microsoft Visual Studio 12.0>"c:\Program Files (x86)\Smar
tBear\TestComplete 10\Bin\TestComplete.exe" "c:\Users\MYNAME\Documents\TestCompl
ete 10 Projects\hig4TestProject1\hig4TestProject1.pjs" /run /project:hig4TestPro
ject1 /test:"KeywordTests|zTdd2_Fail" /exit
C:\Program Files (x86)\Microsoft Visual Studio 12.0>echo %ERRORLEVEL%
0
- It should work when using Start-Process ... -PassThru -Wait:
PS C:\Users\helen> $tc = Start-Process 'C:\Program Files (x86)\SmartBear\TestComplete 10\Bin\TestComplete.exe' '"C:\Users\Public\Documents\TestComplete 10 Samples\Common\Test Log\TestLog.pjs" /run /exit' -PassThru -Wait
PS C:\Users\helen> $tc.ExitCode
2
Sorry I can't be more specific, I don't know PowerShell well.