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
I was migrating from Run Keyword And Ignore Error to TRY-EXCEPT when I encountered the following problem. A developer cannot necessarily know whether their keyword is being run normally or in a teardown but this can dramatically affect how the keyword works.
I can understand the benefit of continuing in teardown to other keywords to make sure that teardown is done as completely as possible but I think that should not occur within a TRY block.
Test code:
*** Test Cases ***
Running TRY Normally
Keyword With TRY
Running TRY In Teardown
Log Test content here.
[Teardown] Keyword With TRY
*** Keywords ***
Keyword With TRY
TRY
Fail First failure
Fail Second failure
EXCEPT First failure
Log In EXCEPT
END
I encountered multiple problems with keywords which are used both normally and in teardown. After thinking this over for a while I'm now hesitant in using TRY-EXCEPT at all and instead relying on older Run Keyword * keywords instead. It seems so dangerous to implement a keyword which works differently based on the context it is being run in.
It's true that execution automatically continuing in teardowns makes using TRY/EXCEPT in them complicated. Need to think is there something we could do to that. Notice that you get the same behavior with Run Keyword And Except Error and others as well.
The underlying problem here is that in teardowns execution continues also after there are failures. This is done to make sure all cleanup activities are run and cannot be changed. Changing the behavior in TRY block could be considered, but I think it is too magic. We'd also need to decide should the mode change affect possible child keywords. A better solution is making to explicitly turn the continue-on-failure mode off when needed. I submitted #4303 about that and hope it could be implemented already in RF 5.1.
The current "unexpected TRY-EXCEPT behavior" is considered to be by design and I close this issue.
Activity
VilleSalonen commentedon Mar 31, 2022
I encountered multiple problems with keywords which are used both normally and in teardown. After thinking this over for a while I'm now hesitant in using TRY-EXCEPT at all and instead relying on older Run Keyword * keywords instead. It seems so dangerous to implement a keyword which works differently based on the context it is being run in.
pekkaklarck commentedon Mar 31, 2022
It's true that execution automatically continuing in teardowns makes using TRY/EXCEPT in them complicated. Need to think is there something we could do to that. Notice that you get the same behavior with
Run Keyword And Except Errorand others as well.pekkaklarck commentedon Apr 7, 2022
The underlying problem here is that in teardowns execution continues also after there are failures. This is done to make sure all cleanup activities are run and cannot be changed. Changing the behavior in
TRYblock could be considered, but I think it is too magic. We'd also need to decide should the mode change affect possible child keywords. A better solution is making to explicitly turn the continue-on-failure mode off when needed. I submitted #4303 about that and hope it could be implemented already in RF 5.1.The current "unexpected TRY-EXCEPT behavior" is considered to be by design and I close this issue.