Skip to content

Support controlling continue-on-failure mode using test and keyword tags #2285

Closed

Description

@jaloren

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.

Activity

  1. pekkaklarck commented on Jan 2, 2016

    @pekkaklarck
    Member

    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.

  2. jaloren commented on Jan 2, 2016

    @jaloren
    ContributorAuthor

    @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

  3. pekkaklarck commented on Jan 2, 2016

    @pekkaklarck
    Member

    Yeah, something like that. Could then also add robot-exit-on-failure.

  4. pekkaklarck commented on Feb 24, 2016

    @pekkaklarck
    Member

    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.

  5. jaloren commented on Feb 25, 2016

    @jaloren
    ContributorAuthor

    I tend to agree that the colon looks cleaner -- mostly aesthetic from my point of view though. Could see someone arguing it either way.

  6. Q-Thomas commented on Jun 21, 2017

    @Q-Thomas

    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?

  7. funhole commented on Nov 2, 2018

    @funhole

    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?

    I have implement on my fork, https://github.com/hellowangsai/robotframework
    You can see the implement details in commits. It is very easy.

  8. pekkaklarck commented on Dec 18, 2018

    @pekkaklarck
    Member

    Some comments/updates:

    • 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.

  9. robinmackaij commented on Mar 13, 2019

    @robinmackaij
    Contributor

    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.

  10. pekkaklarck commented on Mar 14, 2019

    @pekkaklarck
    Member

    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!
  11. pekkaklarck commented on Aug 16, 2019

    @pekkaklarck
    Member

    This is to some extend related to #2603 that proposes adding robot:flatten tag to control how keywords are logged.

  12. jasonaycock commented on Jul 23, 2020

    @jasonaycock

    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_Keyword returns a value. If I use the following I have no way of storing the returned value:

    Run Keyword And Continue On Failure  My_Custom_Keyword
    

    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.

  13. oboehmer commented on Apr 8, 2021

    @oboehmer
    Contributor

    I am currently working on this (check master...oboehmer:2285-continue-tag), check below for current state and proposed new behaviour:

    *** 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.

  14. 5 remaining items

  15. oboehmer commented on Jun 22, 2021

    @oboehmer
    Contributor

    Thanks again for the input on the implementation in #3925. Let me summarize the current state:

    • robot:continue-on-failure will NOT propogate down into user keywords executed from within test cases, this is cleaner and much more obvious
    • it will also not be considered continuable in itself, so the example in Support controlling continue-on-failure mode using test and keyword tags #2285 (comment) above will not execute Log Should this be executed?
    • 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).

  16. added
    acknowledge
    on Jun 24, 2021
  17. 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
  18. 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
  19. pekkaklarck commented on Jun 24, 2021

    @pekkaklarck
    Member

    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.

  20. pekkaklarck commented on Jun 24, 2021

    @pekkaklarck
    Member

    Decisions:

    • 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!

  21. pekkaklarck commented on Apr 7, 2022

    @pekkaklarck
    Member

    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.

  22. khaledElgazzzar commented on May 14, 2023

    @khaledElgazzzar

    is there any tag to fail any following test case if a keyword fail in teardown ?? @pekkaklarck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgepriority: highrc 1

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions