How to capture test results return code

419 views
Skip to first unread message

Rahul Divekar

unread,
May 11, 2021, 3:08:28 PM5/11/21
to robotframework-users
Hello,
I am using following command to run my robot script inside a container thru a shell script. 

e.g. robot -d Test_Results ./Smoke_Test.robot

depending upon the Pass/Fail result of my smoke test, i need to do further processing.
Can anyone please guide me to with - Is there a way to verify if all test passed or failed flag when i run above command in shell prompt. 

TIA.
Rahul D.

Craig Despeaux

unread,
May 11, 2021, 4:35:53 PM5/11/21
to robotframework-users
Assuming you're running in a Linux environment, after robot runs you can check the exit code in bash using $?.  

If all the tests passed, the exit code should be 0.

if [ $? -eq 0 ]; then
  echo "all the tests passed!"
else
  echo "one or more tests failed!"
fi

Craig


Dave Amies

unread,
May 11, 2021, 8:41:27 PM5/11/21
to robotframework-users
And the equivalent on windows is %errorlevel%

in a windows batch/command file:
IF "%errorlevel%"=="0" (
    echo "all the tests passed!"
) ELSE (
    echo "one or more tests failed!"
)

Dave.

Rahul Divekar

unread,
May 12, 2021, 6:15:34 AM5/12/21
to robotframework-users
Thank you for your response. It worked!
Reply all
Reply to author
Forward
0 new messages