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
{{ message }}
Repository navigation
Support controlling continue-on-failure mode using test and keyword tags #2285
The continue on failure mode allows execution to continue after a keyword has failed. This functionality is very useful but has a couple short comings.
Problem
Outside of custom keywords defined in a python library, a user must leverage additional keywords on top of the existing keyword which can significantly increase verbosity and complexity of custom keywords (e.g Run Keyword And Continue On Failure, Run Keyword and Return Status, and Run Keyword If).
there is no easy way to turn continue on failure mode on for setup like one has it for teardown
there is no easy way to run continue on failure mode off for teardown like it works for set up.
proposed solution
after discussing this with Pekka, current proposal is to implement reserved tags.
robot-continue-on-failure
robot-stop-on-failure
robot-exit-on-failure.
UPDATE: Tags that int the end were implemented are robot:continue-on-failure and robot:recursive-continue-on-failure. See the discussion below for details.
I agree on the problem. Instead of having separate keywords to turn the mode on or off, I would prefer user keywords having a way to explicitly set the mode. It could be done with a new setting like [Continue Mode] or with a special keyword tag like robot:continue-on-failure. Using tags would be a lot easier to implement and would not require syntax changes that editors and other tools would need to support.
@pekkaklarck: I forgot that newer versions of RF allow setting tags in a keyword and I hadn't realized there was such a thing as a reserved tag . Given that, the tag approach sounds nice, especially since that means the RF report and stats will automatically identify and flag any keyword or test cases that use it.
According to the documentation, a reserved tag is denoted with robot- so does that mean it would be something like:
No activity here lately, but I consider this so important that hopefully we get it implemented at some point.
We can still consider using robot: prefix instead of robot- prefix with reserved tags. For some reason I nowadays consider the former better. I think they only have one usage at the moment so changing is possible.
Hi Guys, any plans of implementing this feature? Thanks!
If you have some pointers on how to implement this, I would be willing to have a look myself and create a pull-request?
Hi Guys, any plans of implementing this feature? Thanks!
If you have some pointers on how to implement this, I would be willing to have a look myself and create a pull-request?
We've decided to use robot: prefix with reserved tags, so we should use robot:continue-on-failure here as well.
Having a way to turn off the continue-on-failure mode would be useful both in teardowns and when the mode is explicitly enabled with robot:continue-on-failure. I think it should get a separate issue, though, because enabling continue-on-failure is useful also alone. I would propose using robot:no-continue-on-failure tag for that instead of robot:stop-on-failure. We could then use the same no- prefix with other similar modes as well and we already have robot:no-dry-run.
Enabling exit-on-failure mode (i.e. stopping the whole execution on a failure) could be useful as well, but definitely needs its own issue.
What is the status of this issue? I'm interested in looking into it, if time permits.
Question I have is how this tag will behave when going down the tree; if a Test Case is tagged to continue-on-failure (so all keywords behave like they have the Run Keyword And Ignore Error keyword before them) and the User Keyword being called is tagged to stop-on-failure, what happens if a keyword within that User Keyword fails? I would expect it to work like setup and teardown, where the lowest level takes precedence, but I'd like an official answer on that one.
I've been thinking these tags should only have a meaning when used with keywords, but being able to use them with tests to change the default behavior could be useful as well. Should then think should such tags be automatically removed from test statistics. Anyway, I'd start with keyword tags.
If we add both robot:continue-on-failure and robot:stop-on-failure (or robot:no-continue-on-failure) and they are nested, the lowest should have precedence.
Should also make a decision should robot:continue-on-failure be recursive or not. I guess it should be, which would mean that Log Should this be executed? in the example below would be executed. We could also argue that if we wanted to continue also on that level, then we should use robot:continue-on-failure there as well.
*** Keywords ***Example[Tags] robot:continue-on-failure
Keyword 1
Keyword 2
Keyword 1
Fail Something goes wrong here...
Log Should this be executed?
Keyword 2
Log This should definitely be executed!
*** Test Cases ***
Test case 1
[Tags] robot:continue-on-failure
Fail foo1
Log This is executed
keyword 1
keyword 2
Log This is executed
Test case 2
keyword 1
Log This is NOT executed
Test case 3
[Tags] robot:continue-on-failure
FOR ${i} IN foo bar··
Fail loop-${i}
END
Log This is executed
*** Keywords ***
keyword 1
Fail foo2
Log This is executed if called from test with robot:continue-on-failure set
Fail foo3
Keyword 2
[Tags] robot:no-continue-on-failure
Fail foo4
Log This is NOT executed
Fail foo5
Running this test produces
==============================================================================
continue-test
==============================================================================
Test case 1 | FAIL |
Several failures occurred:
1) foo1
2) foo2
3) foo3
4) foo4
------------------------------------------------------------------------------
Test case 2 | FAIL |
foo2
------------------------------------------------------------------------------
Test case 3 | FAIL |
Several failures occurred:
1) loop-foo
2) loop-bar
------------------------------------------------------------------------------
continue-test | FAIL |
3 tests, 0 passed, 3 failed
==============================================================================
Working with Pekka on this, but wanted to raise awareness to folks who commented on this thread and solicit feedback/input.
I changed the implementation to leverage the context which is already present in all runners, which simplifies it quite a bit
it also extends the robot:continue-on-failure to keywords executed via Run Keywords
With the new implementation, honoring propagation from tests into user keywords or from user keywords into user keywords extremely simple. I am therefore suggesting a dedicated robot:continue-on-failure-recursive (working title) tag which does propogate down. This is unconditional, so no capability to override this through robot:no-continue-on-failure is provided (this tag is not checked anywhere).
changed the title [-] improve usability of "continue on failure" mode[/-][+]Support controlling contnue-on-failure mode using test and keyword tags[/+]on Jun 24, 2021
changed the title [-]Support controlling contnue-on-failure mode using test and keyword tags[/-][+]Support controlling continue-on-failure mode using test and keyword tags[/+]on Jun 24, 2021
After PR #3925 by @oboehmer being merged, the main functionality is now implemented. This is what works now:
robot:continue-on-failure tag means that the test or keyword using it will continue execution even if its keywords fail. This is not recursive, so in used keywords execution stops for the first failure (unless the same tag is also used there).
robot:continue-on-failure-recursive works like the above but in recursive manner. This tag may still be renamed to robot:recursive-continue-on-failure.
We may still add robot:no-continue-on-failure to make sure the continue-on-failure mode isn't used. It's main usage would be disabling the effect of robot:continue-on-failure-recursive, but we could also look at supporting it in teardowns and with tests having templates where continue-on-failure is the default mode. This enhancement can be done also in future versions, not in RF 4.1.
robot:continue-on-failure-recursive was renamed to robot:recursive-continue-on-failure.
robot:no-continue-on-failure will not be implemented now. Separate issue can be submitted about it if/when it's considered useful.
Tests as well as handling of tags in statistics has also been enhanced a bit. I don't think there's anything else to do so we can finally consider this issue done. Thanks for contribution @oboehmer!
There seem to be now needs for robot:no-continue-on-failure (#4303) that was discussed already when this issue was implemented. I haven't heard concrete requests for adding it to disable robot:recursive-continue-on-failure added as part of this issue, but #4293 made it clear it would be convenient with teardowns.
Activity
pekkaklarck commentedon Jan 2, 2016
I agree on the problem. Instead of having separate keywords to turn the mode on or off, I would prefer user keywords having a way to explicitly set the mode. It could be done with a new setting like
[Continue Mode]or with a special keyword tag likerobot:continue-on-failure. Using tags would be a lot easier to implement and would not require syntax changes that editors and other tools would need to support.jaloren commentedon Jan 2, 2016
@pekkaklarck: I forgot that newer versions of RF allow setting tags in a keyword and I hadn't realized there was such a thing as a reserved tag . Given that, the tag approach sounds nice, especially since that means the RF report and stats will automatically identify and flag any keyword or test cases that use it.
According to the documentation, a reserved tag is denoted with robot- so does that mean it would be something like:
robot-continue-on-failure
robot-stop-on-failure
pekkaklarck commentedon Jan 2, 2016
Yeah, something like that. Could then also add
robot-exit-on-failure.pekkaklarck commentedon Feb 24, 2016
No activity here lately, but I consider this so important that hopefully we get it implemented at some point.
We can still consider using
robot:prefix instead ofrobot-prefix with reserved tags. For some reason I nowadays consider the former better. I think they only have one usage at the moment so changing is possible.jaloren commentedon Feb 25, 2016
I tend to agree that the colon looks cleaner -- mostly aesthetic from my point of view though. Could see someone arguing it either way.
Q-Thomas commentedon Jun 21, 2017
Hi Guys, any plans of implementing this feature? Thanks!
If you have some pointers on how to implement this, I would be willing to have a look myself and create a pull-request?
funhole commentedon Nov 2, 2018
I have implement on my fork, https://github.com/hellowangsai/robotframework
You can see the implement details in commits. It is very easy.
pekkaklarck commentedon Dec 18, 2018
Some comments/updates:
We've decided to use
robot:prefix with reserved tags, so we should userobot:continue-on-failurehere as well.Having a way to turn off the continue-on-failure mode would be useful both in teardowns and when the mode is explicitly enabled with
robot:continue-on-failure. I think it should get a separate issue, though, because enabling continue-on-failure is useful also alone. I would propose usingrobot:no-continue-on-failuretag for that instead ofrobot:stop-on-failure. We could then use the sameno-prefix with other similar modes as well and we already haverobot:no-dry-run.Enabling exit-on-failure mode (i.e. stopping the whole execution on a failure) could be useful as well, but definitely needs its own issue.
robinmackaij commentedon Mar 13, 2019
What is the status of this issue? I'm interested in looking into it, if time permits.
Question I have is how this tag will behave when going down the tree; if a Test Case is tagged to continue-on-failure (so all keywords behave like they have the Run Keyword And Ignore Error keyword before them) and the User Keyword being called is tagged to stop-on-failure, what happens if a keyword within that User Keyword fails? I would expect it to work like setup and teardown, where the lowest level takes precedence, but I'd like an official answer on that one.
pekkaklarck commentedon Mar 14, 2019
I've been thinking these tags should only have a meaning when used with keywords, but being able to use them with tests to change the default behavior could be useful as well. Should then think should such tags be automatically removed from test statistics. Anyway, I'd start with keyword tags.
If we add both
robot:continue-on-failureandrobot:stop-on-failure(orrobot:no-continue-on-failure) and they are nested, the lowest should have precedence.Should also make a decision should
robot:continue-on-failurebe recursive or not. I guess it should be, which would mean thatLog Should this be executed?in the example below would be executed. We could also argue that if we wanted to continue also on that level, then we should userobot:continue-on-failurethere as well.pekkaklarck commentedon Aug 16, 2019
This is to some extend related to #2603 that proposes adding
robot:flattentag to control how keywords are logged.jasonaycock commentedon Jul 23, 2020
Has there been any progress on this? Currently the user manual shows only two reserved tags,
robot:exit, and,robot:no-dry-run.I am asking because I have a similar use case.
My_Custom_Keywordreturns a value. If I use the following I have no way of storing the returned value:If I could use the tag,
robot:continue-on-failure, in either my Keyword or my Test Case then this would no longer be an issue.oboehmer commentedon Apr 8, 2021
I am currently working on this (check master...oboehmer:2285-continue-tag), check below for current state and proposed new behaviour:
Running this test produces
Working with Pekka on this, but wanted to raise awareness to folks who commented on this thread and solicit feedback/input.
5 remaining items
oboehmer commentedon Jun 22, 2021
Thanks again for the input on the implementation in #3925. Let me summarize the current state:
robot:continue-on-failurewill NOT propogate down into user keywords executed from within test cases, this is cleaner and much more obviousLog Should this be executed?Run KeywordsWith the new implementation, honoring propagation from tests into user keywords or from user keywords into user keywords extremely simple. I am therefore suggesting a dedicated
robot:continue-on-failure-recursive(working title) tag which does propogate down. This is unconditional, so no capability to override this throughrobot:no-continue-on-failureis provided (this tag is not checked anywhere).Enable continuable failures via robot:continue-on-failure test or kw …
[-] improve usability of "continue on failure" mode[/-][+]Support controlling contnue-on-failure mode using test and keyword tags[/+][-]Support controlling contnue-on-failure mode using test and keyword tags[/-][+]Support controlling continue-on-failure mode using test and keyword tags[/+]pekkaklarck commentedon Jun 24, 2021
After PR #3925 by @oboehmer being merged, the main functionality is now implemented. This is what works now:
robot:continue-on-failuretag means that the test or keyword using it will continue execution even if its keywords fail. This is not recursive, so in used keywords execution stops for the first failure (unless the same tag is also used there).robot:continue-on-failure-recursiveworks like the above but in recursive manner. This tag may still be renamed torobot:recursive-continue-on-failure.We may still add
robot:no-continue-on-failureto make sure the continue-on-failure mode isn't used. It's main usage would be disabling the effect ofrobot:continue-on-failure-recursive, but we could also look at supporting it in teardowns and with tests having templates where continue-on-failure is the default mode. This enhancement can be done also in future versions, not in RF 4.1.Rename robot:continue-on-failure-recursive tag to robot:recursive-con…
Test robot:recursive-continue-on-failure w/ nested keyword
pekkaklarck commentedon Jun 24, 2021
Decisions:
robot:continue-on-failure-recursivewas renamed torobot:recursive-continue-on-failure.robot:no-continue-on-failurewill not be implemented now. Separate issue can be submitted about it if/when it's considered useful.Tests as well as handling of tags in statistics has also been enhanced a bit. I don't think there's anything else to do so we can finally consider this issue done. Thanks for contribution @oboehmer!
pekkaklarck commentedon Apr 7, 2022
There seem to be now needs for
robot:no-continue-on-failure(#4303) that was discussed already when this issue was implemented. I haven't heard concrete requests for adding it to disablerobot:recursive-continue-on-failureadded as part of this issue, but #4293 made it clear it would be convenient with teardowns.khaledElgazzzar commentedon May 14, 2023
is there any tag to fail any following test case if a keyword fail in teardown ?? @pekkaklarck