Skip to content

New SKIP status #3622

Closed
Closed

Description

@pekkaklarck

We already have #2087 about this long request functionality, but that issue has grown so big with all the comments that I decided to create a fresh one. The major difference between the old issue and this one is that while the old one was mainly for discussing about the design, this issue is about actually getting the feature implemented. I now have the high level design ready and explain it below. The plan is to have this feature in RF 4.0 still during 2020.

How to skip tests

There are going to be multiple ways:

  • A special exception that library keywords can use to mark a single test to be skipped. See also Expose special exceptions via robot.api #3685.
  • BuiltIn keyword Skip (or Skip Test and Skip Task) that utilizes the aforementioned exception.
  • BuiltIn keyowrd Skip If to skip based on condition.
  • When the skipping exception is used in a suite setup, all tests in the suite are skipped.
  • Command line option --skip to unconditionally skip tests based on tags. Similar to --exclude but skipped tests are shown in logs/reports with a skip status and not dropped from execution altogether.
  • Command line option --skiponfailure to skip tests if they fail. Similar effect than with the current --noncritical.

What about criticality

As already discussed in #2087, the skip status is very similar feature than Robot's current criticality concept. There are many people who would like to have both, but I don't think that's a good idea and believe it's better to remove criticality when skipping is added. Separate issue #3624 covers removing criticality and explains this in more detail.

Colors

Skip status needs a specific color to match current pass (green) and fail (red). Yellow feels like a good candidate with a traffic light metaphor, but I'm open for other ideas and we could possibly change other colors as well. Probably should make colors configurable too -- currently only report background colors support it.

Report background color mentioned above needs some thinking as well. Currently it's either green or red, but with the added skip status we could use also yellow or whatever skip color we decide to use. Different scenarios where different colors could be used are listed below (assuming green/yellow/red scheme):

  • All tests pass. This is naturally green.
  • Any test fails. This is naturally red.
  • Any test is skipped (no failures). This probably should be green but could also be yellow.
  • All tests skipped. This could be yellow. Could also be green but that's a bit odd if all tests are yellow.

Activity

  1. added this to the v4.0 milestone on Jul 30, 2020
  2. skhomuti commented on Jul 30, 2020

    @skhomuti

    About colors - yellow can be used for broken tests if a similar idea is considered. We discussed this approach in #3054.

    For skipped tests, can gray be considered? Such colors are used in the Allure framework, as well as a similar analogy with untested tests in TestRail.

    image

    image

  3. pekkaklarck commented on Jul 30, 2020

    @pekkaklarck
    MemberAuthor

    Using gray color with skipped tests could work fine. It's probably better to discuss this more when the basic functionality is implemented and it's easy to test different options simply by changing colors in CSS.

  4. changed the title [-]New `SKIP` status for tests[/-] [+]New `SKIP` status[/+] on Sep 10, 2020
  5. adiralashiva8 commented on Sep 14, 2020

    @adiralashiva8

    Skip Impacted Areas:

    • Robotframework API
    • Robotframework Listeners
    • Log/Report/Xml files

    Following tools uses listener/api

    Plugins/Notification

    • Jenkins Plugins
    • Slack/Teams etc.,

    Tools:

    • Tesults
    • ReportPortal
    • Allure
    • TestArchiver/RfHistoric
  6. robinmackaij commented on Sep 14, 2020

    @robinmackaij
    Contributor

    Using gray color with skipped tests could work fine. It's probably better to discuss this more when the basic functionality is implemented and it's easy to test different options simply by changing colors in CSS.

    I can see a case for both gray and yellow (or orange) based on the reason for skipping:

    • gray for 'statically skipped' test, i.e. test skipped due to the --skip TAG and robot:skip options. In other words, tests that we know in advance will be skipped. Gray would be my color of choice here since it's neutral...we knew this outcome was coming, nothing unexpected.
    • yellow / orange for 'dynamically skipped' tests...the tests that were skipped due to some failure. These are the tests that we expected to pass but didn't, but we also don't want to consider them failed (and we did something to make sure they are marked skipped instead of failed).

    Now I realize this is somewhat more advanced and perhaps too far reaching. A compromise could be to let the user choose between gray and yellow/orange, but if we offer the user a way to pick their own color for each status, that's not even needed.

  7. added a commit that references this issue on Sep 28, 2020
  8. pekkaklarck commented on Sep 30, 2020

    @pekkaklarck
    MemberAuthor

    There's been great progress related to this in PR #3682 and in some commits afterwards. While getting the basic functionality implemented, we've encountered some corner cases that need to be handled:

    1. Should skip be allowed in test teardown? If yes, what should happen if there has been a failure earlier?

    2. What about suite teardown? Should skip be allowed there at all? If it is, should it retroactively skip all tests similarly as failing suite teardown fails all tests? What if some test has previously failed?

    3. If a test is skipped, should possible teardown be executed?

    4. How should skip work if a continuable failure (i.e. a failure that allow execution to continue but cause test to be failed at the end) has occurred earlier? Should the test be skipped and the earlier failure hidden or should this cause an explicit error?

  9. pekkaklarck commented on Sep 30, 2020

    @pekkaklarck
    MemberAuthor

    The current plan, based on the discussion with @yanne and I, is that we allow skip everywhere but try not to totally hide earlier failures. In practice that means the following:

    1. Skip would be allowed in teardown. When used, further keywords in teardown aren't executed. If there has been a failure earlier, the failure message will be included in the final test message. The test will get SKIP status regardless have there been failures or not.

    2. Behavior in suite teardown is still somewhat open. Working like failures in suite teardown sounds quite logical but that requires some extra work. An alternative is just disallowing skip there.

    3. Teardowns won't be executed if a test is skipped explicitly with Skip keyword or otherwise. If a test fails and is marked skipped due to using --skiponfailure, teardown is executed normally.

    4. If a continuable failure has occurred before skip, that failure will be included in the final test message but test status will nevertheless be SKIP. Basically same approach as with teardowns when there have been failures earlier.

    The above design is currently just a plan and hasn't yet been implemented. If you disagree with something, please voice your concerns now so that they can possibly be still taken into account.

  10. robinmackaij commented on Sep 30, 2020

    @robinmackaij
    Contributor

    The current plan, based on the discussion with @yanne and I, is that we allow skip everywhere but try not to totally hide earlier failures. In practice that means the following:

    1. Skip would be allowed in teardown. When used, further keywords in teardown aren't executed. If there has been a failure earlier, the failure message will be included in the final test message. The test will get SKIP status regardless have there been failures or not.
    

    I would say the test status stays FAIL for the simple reason that the test itself failed. We're skipping cleaning up after performing the test; that does not change the outcome of the test itself.

    2. Behavior in suite teardown is still somewhat open. Working like failures in suite teardown sounds quite logical but that requires some extra work. An alternative is just disallowing skip there.
    

    Suite teardown is a tricky one. All tests have been executed, the results are known. Nothing in the suite teardown should change that in my opinion. Any failures or skips in a suite teardown could perhaps be a warning in the logs.

    3. Teardowns won't be executed if a test is skipped explicitly with `Skip` keyword or otherwise. If a test fails and is marked skipped due to using `--skiponfailure`, teardown is executed normally.
    

    This is somewhat tricky. If a test setup did some stuff, odds are cleanup is needed regardless of pass/fail/skip of the test itself. At the same time, it's also common that the test itself does something that needs to be cleaned up and in that case, the teardown should to be skipped if the test is skipped.

    I'm leaning towards just executing the teardown unless the test is "statically skipped" (i.e. skipped due to tag or command line flag).

    4. If a continuable failure has occurred before skip, that failure will be included in the final test message but test status will nevertheless be SKIP. Basically same approach as with teardowns when there have been failures earlier.
    

    As with 1. I'd keep the FAIL result since that is the outcome of the test itself.

  11. pekkaklarck commented on Oct 1, 2020

    @pekkaklarck
    MemberAuthor

    The decision between FAIL or SKIP status when there have been earlier failures (cases 1. and 4.) is pretty hard but I still think explicit SKIP is better if we include information about the failure in the final message. This situation ought to be so rare that the decision shouldn't matter much either way.

    Executing or not executing test teardown when the test is started but it uses skip is really hard and I'm starting to think always executing the teardown is probably the best solution. For this to work well, behavior should then be such that failures in teardown after skipping shouldn't turn the status to FAIL but leave it SKIP.

    Failures in suite teardown currently cause all tests in the suite to be marked failed. The motivation is that otherwise you wouldn't really see this situation in the report at all. This has been discussed earlier and and the design won't change. There is, however, keywords like Run Keyword And Ignore Error and the planned Run Keyword And Warn On Error that can be used to ensure the teardown cannot fail. Possible skip in suite teardown marking tests skipped would thus be consistent with this behavior and shouldn't be overly complicated to implement either. The alternative is disallowing skip in suite teardowns but that requires some work as well.

  12. robinmackaij commented on Oct 4, 2020

    @robinmackaij
    Contributor

    The decision between FAIL or SKIP status when there have been earlier failures (cases 1. and 4.) is pretty hard but I still think explicit SKIP is better if we include information about the failure in the final message. This situation ought to be so rare that the decision shouldn't matter much either way.

    It should be a rare case, but I dislike the implication; having to check all SKIPS to see if any of them is due to a skipped teardown after a failed test. Of course the base behavior could be overridden using the Listener Interface, but still I prefer FAIL remaining FAIL since it's more serious than a SKIP.

    Executing or not executing test teardown when the test is started but it uses skip is really hard and I'm starting to think always executing the teardown is probably the best solution. For this to work well, behavior should then be such that failures in teardown after skipping shouldn't turn the status to FAIL but leave it SKIP.

    I agree that that would be the best way to go. The status of the test case itself would stand and one could find teardown failures in the logs. Once 'if / else' is in, that could also be used in the teardown based on the test case result to implement more advanced scenarios. Covering all possible scenarios could otherwise mean a lot of command line flags, which is never a good thing.

    Failures in suite teardown currently cause all tests in the suite to be marked failed. The motivation is that otherwise you wouldn't really see this situation in the report at all. This has been discussed earlier and and the design won't change. There is, however, keywords like Run Keyword And Ignore Error and the planned Run Keyword And Warn On Error that can be used to ensure the teardown cannot fail. Possible skip in suite teardown marking tests skipped would thus be consistent with this behavior and shouldn't be overly complicated to implement either. The alternative is disallowing skip in suite teardowns but that requires some work as well.

    Skip in teardown turning failed tests into skipped tests is not something I would like (as stated above), so I would dislike that solution. At the same time, it's an edge case I think, and with Ignore Error / Warn On Error there's good ways to tweak it to ones needs / likes. For that reason, I'd go with the easier implementation.

  13. 7 remaining items

  14. pekkaklarck commented on Oct 18, 2020

    @pekkaklarck
    MemberAuthor

    Libraries can utilize skip by raising a special exception indicating that the current test should be skipped. It's easiest to use the new robot.api.SkipExecution exception (see #3685 for other similarly exposed exceptions):

    from robot.api import SkipExecution
    
    def example():
        if the_test_should_be_skipped():
            raise SkipExecution('Test skipped for some good reason')

    Alternatively it's possible to create a custom exception that has a special ROBOT_SKIP_EXECUTION attribute set to a true value:

    class Skip(Exception):
        ROBOT_SKIP_EXECUTION = True
    
    def example():
        if the_test_should_be_skipped():
            raise Skip('Test skipped for some good reason')

    Notice that the attribute name used to be ROBOT_SKIP_ON_FAILURE but it was changed to ROBOT_SKIP_EXECUTION in 685f78e.

  15. pekkaklarck commented on Nov 25, 2020

    @pekkaklarck
    MemberAuthor

    This issue is backwards compatible because it introduces a new status that external tools using Robot's result APIs or parsing output.xml need to take into account.

  16. pekkaklarck commented on Nov 25, 2020

    @pekkaklarck
    MemberAuthor

    This features was already included in RF 4.0 alpha 1 and some problems have been fixed since that. It ought to be be adequately documented now as well. The only thing I think is needed before we can finally close this issue is fixing problems with Run Keyword * keywords explained in #3755. Colors probably should still be fine-tuned as well, but that doesn't affect the overall functionality and can be done after closing this issue.

  17. pekkaklarck commented on Nov 26, 2020

    @pekkaklarck
    MemberAuthor

    Run Keyword * problems explained in #3755 are fixed. Colors can be fine-tuned later so this issue can be considered done. 🎉

  18. Pratapreddy1188 commented on Jul 12, 2023

    @Pratapreddy1188

    Hi is there any option to filterout skipped tests from the output.xml and rerun them.
    Example , I have a test suite with 10 test and 6 tests pass 7th failed and with exiton failure remaining are skipped.
    Now i want to rerun my remaining tests 8,9 and 10. leaving 7.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions