Skip to content

Support disabling continue-on-failure mode using robot:stop-on-failure and robot:recursive-stop-on-failure tags #4303

Closed

Description

@pekkaklarck

When a keyword fails, Robot's default behavior is to stop executing the current test or a user keyword. There are, however, few cases where the remaining keywords in the test/keyword are run (i.e. the continue-on-failure mode is on):

  1. When robot:continue-on-failure or robot:recursive-continue-on-failure tags have been used (Support controlling continue-on-failure mode using test and keyword tags #2285).
  2. When executing keywords in test or keyword teardown.
  3. When a test has a template, all top level iterations are run even if one of them would fail.

It would sometimes be convenient to be able to turn the continue-on-failure more off in the above cases. A concrete example is #4293, where TRY/EXCEPT behaves differently in teardowns and elsewhere. When robot:recursive-continue-on-failure was added, we discussed about adding robot:no-continue-on-failure to be able to disable it. It wasn't done then, but now would be a good time. For consistency reasons we should also support templates.


UPDATE: We decided to use robot:stop-on-failure tag and also added recursive variant robot:recursive-stop-on-failure.

Activity

  1. added this to the v5.1 milestone on Apr 7, 2022
  2. oboehmer commented on Apr 7, 2022

    @oboehmer
    Contributor

    I can take this, @pekkaklarck ..

  3. pekkaklarck commented on Apr 7, 2022

    @pekkaklarck
    MemberAuthor

    That would be great @oboehmer!

  4. pekkaklarck commented on Apr 7, 2022

    @pekkaklarck
    MemberAuthor

    I think the only design decision related to this is deciding should robot:no-continue-on-failure be recursive or not. I got a feeling it should be recursive even though it would be inconsistent with robot:continue-on-failure. Alternatively we could add separate robot:recursive-no-continue-on-failure but that's getting pretty complicated.

  5. oboehmer commented on Apr 7, 2022

    @oboehmer
    Contributor

    I would opt for it not to be recursive.. Not to continue is the default, so why should it be recursive? Let me create a PR shortly, we can discuss there..

  6. oboehmer commented on Apr 7, 2022

    @oboehmer
    Contributor

    please check #4306

  7. oboehmer commented on Apr 7, 2022

    @oboehmer
    Contributor

    one question is also if a test-level robot:no-continue-on-failure would propagate into the Teardown method or not?

    No-continue-on-failure-2 in Teardown
        [Documentation]    FAIL 1
        [Tags]   robot:no-continue-on-failure
        [Teardown]   Run Keywords   Fail   1   AND   Fail  2
        Log    does not matter
    

    At the moment this is passing (i.e. Fail 2 is not executed), but it feels odd.. if a user wants to avoid continue in teardown, he needs to use a user keyword..

    Edit: Sleeping over it: to support disabling continue in user keyword teardown, we would need a similar design pattern, so maybe we should honor the test case tag as well in continue:

    *** Keywords ***
    User Keyword Teardown
        [Tags]   robot:no-continue-on-failure
        [Teardown]   Run Keywords    Fail  kw1a   AND   Fail   kw1b
        No Operation
    

    So maybe the documentation will be like:

    setting the tag robot:no-continue-on-failure on a test case or on a keyword will disable continue on failure both in the test case/keyword as well as in the test case/keyword teardown.

    If overloading this doesn't look right, we could introduce a distinct robot:no-continue-on-failure-in-teardown tag which would make this behaviour more explicit..

  8. pekkaklarck commented on Apr 8, 2022

    @pekkaklarck
    MemberAuthor

    The reason I got a feeling robot:no-continue-on-failure should be recursive is that then you could just set it once for the teardown keyword. Otherwise you needed to set it to all keywords used in teardowns to make sure TRY/EXCEPT works consistently (#4293). Same thing if you want to stop robot:recursive-continue-on-failure from propagating. It would be odd if continue-on-failure mode would be off in a keyword using robot:no-continue-on-failure but would again be enabled in keywords used by it.

    robot:no-continue-on-failure being recursive when robot:continue-on-failure is not is obviously somewhat inconsistent. Possible solutions:

    • Add both robot:no-continue-on-failure and robot:recursive-no-continue-on-failure to match the earlier added robot:continue-on-failure and robot:recursive-continue-on-failure. That robot:recursive-no-continue-on-failure is a rather long tag name, but this would be a pretty explicit, consistent and backwards compatible solution.
    • Change robot:continue-on-failure to be recursive and deprecate robot:recursive-continue-on-failure. Having just robot:continue-on-failure and robot:no-continue-on-failure would be simpler but not being able to limit continue-on-failure only to a certain level could be problematic. This would obviously be a backwards incompatible change as well.
  9. pekkaklarck commented on Apr 8, 2022

    @pekkaklarck
    MemberAuthor

    I think test level robot:no-continue-on-failure should not affect teardowns. We can think teardowns having implicit robot:recursive-continue-on-failure set and it overrides possible higher level configuration.

  10. pekkaklarck commented on Apr 8, 2022

    @pekkaklarck
    MemberAuthor

    Sorry, don't have time to look at PRs today. It would be important to agree on the semantics first anyway. That might be something to discuss further on Slack.

  11. oboehmer commented on Apr 8, 2022

    @oboehmer
    Contributor

    agree, started a thread on slack..

  12. pekkaklarck commented on Apr 12, 2022

    @pekkaklarck
    MemberAuthor

    I've been thinking this a bit more and here's how I currently think we should do this:

    • Let's use robot:stop-on-failure instead of robot:no-continue-on-failure.
    • Make it not recursive to match how robot:continue-on-failure works.
    • Add also robot:recursive-stop-on-failure to match robot:recursive-continue-on-failure.
    • Neither stop-on-failure variants should propagate to teardowns. We can think them having robot:recursive-continue-on-failure implicitly. To enable the stop-on-failure mode in teardowns, these special tags need to be used explicitly.
  13. oboehmer commented on Apr 13, 2022

    @oboehmer
    Contributor

    @pekkaklarck , I created PR #4313 based on the recent design discussions. Please review when you have a chance.

  14. pekkaklarck commented on Apr 14, 2022

    @pekkaklarck
    MemberAuthor

    Thanks for the PR! I won't have time to look at it in the immediate future but hopefully next week. I want to do few things in master before we create a maintenance branch for RF 5.0.x and start merging RF 5.1 features.

  15. added
    acknowledge
    on Jun 9, 2022
  16. pekkaklarck commented on Jun 9, 2022

    @pekkaklarck
    MemberAuthor

    This was implemented in PR #4313 by @oboehmer. Thanks for a great contribution!

  17. changed the title [-]Support disabling continue-on-failure mode[/-] [+]Support disabling continue-on-failure mode using `robot:stop-on-failure` and `robot:recursive-stop-on-failure` tags[/+] on Jul 4, 2022
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

    acknowledgealpha 1priority: high

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions