Skip to content

Keyword teardown is not executed if test or keyword timeout occurs #5474

@gschwaer

Description

@gschwaer

Hi,

I have a user keyword that may leave a mess if it's not cleaned up after. So I have a user keyword teardown which does that. But if it is stopped early due to a test case timeout, the teardown is not executed. What to do?

Example:

# test.robot
*** Test Cases ***
Test with timeout
    [Timeout]    2s
    Keyword with teardown

Test which will find a mess
    Fail    Oh what a mess! Why did somebody not clean up after themselves!?


*** Keywords ***
Keyword with teardown
    [Setup]    Log    Doing the setup
    Sleep    24h    # This hangs
    [Teardown]    Log    Doing cleanup    # This is not executed, so how do I clean up?

Run:

$ robot test.robot
==============================================================================
Test                                                                          
==============================================================================
Test with timeout                                                     | FAIL |
Test timeout 2 seconds exceeded.

Also keyword teardown failed:
Test timeout 2 seconds exceeded.
------------------------------------------------------------------------------
Test which will find a mess                                           | FAIL |
Oh what a mess! Why did somebody not clean up after themselves!?
------------------------------------------------------------------------------
Test                                                                  | FAIL |
2 tests, 0 passed, 2 failed
==============================================================================
Output:  /home/gschwaer/tests/robot-framework/output.xml
Log:     /home/gschwaer/tests/robot-framework/log.html
Report:  /home/gschwaer/tests/robot-framework/report.html

Unfortunately

Thanks for you help in advance!

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions