You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Failing keywords in teardown are not handled with TRY/EXCEPT:
Sample robot file:
*** Settings ***
Test Teardown TeardownKW
*** Keywords ***
TeardownKW
TRY
Fail 1
Fail 2
RETURN
EXCEPT
Log err handled
END
*** Test Cases ***
DraftTest
Log This test is used for experiments.
Results in:
Expected: Keywords Fail 2 and RETURN should not be executed due to Fail 1 is failing.
Failures don't stop execution in teardown because we want all cleanup activities to be done. That means TRY/EXCEPT structures work differently in teardowns than elsewhere and this was already reported as #4293. As you can see in the comments of that issue, we decided not to change this because teardown behavior changing inside TRY/EXCEPT would have been strange and also complicated to implement. We instead decided to make it possible to explicitly disable the continue-on-failure mode that's automatically on in teardowns. For more details about that see #4303.
Would you consider the below best practice: prioritzing robot:recursive-stop-on-failure over robot:stop-on-failure in teardown?
We could add this to the Robot Framework User Guide.
*** Settings ***Documentation I am MyResource.resource*** Keywords ***Common Complex Operation Used In Many Tests # [Tags] robot:stop-on-failure # We want to avoid putting the above tag in many kewords
TRY
Log I am an operation that succeeds or fails 50/50 of the time
RETURN ${True}
EXCEPT
RETURN ${False}
END
*** Settings ***Documentation I am a Robot file with a testResource MyResource.resource
Test Teardown Teardown After Every Test
*** Test Cases ***Test One
Log I am checking something in Test One
*** Keywords ***I Am Required In Teardown[Tags] robot:recursive-stop-on-failure # Best way is to put this recursive tag here, where the behavior is required.
Common Complex Operation Used In Many Tests
I Am Also Required In Teardown Please
Log Doing some teardown stuff
Teardown After Every Test
I Am Required In Teardown
I Am Also Required In Teardown Please
Activity
pekkaklarck commentedon Aug 9, 2022
Failures don't stop execution in teardown because we want all cleanup activities to be done. That means TRY/EXCEPT structures work differently in teardowns than elsewhere and this was already reported as #4293. As you can see in the comments of that issue, we decided not to change this because teardown behavior changing inside TRY/EXCEPT would have been strange and also complicated to implement. We instead decided to make it possible to explicitly disable the continue-on-failure mode that's automatically on in teardowns. For more details about that see #4303.
alainsiroishw commentedon Dec 6, 2025
Hello @pekkaklarck
Would you consider the below best practice: prioritzing
robot:recursive-stop-on-failureoverrobot:stop-on-failurein teardown?We could add this to the Robot Framework User Guide.