Repository navigation
Description
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(orSkip TestandSkip Task) that utilizes the aforementioned exception. - BuiltIn keyowrd
Skip Ifto skip based on condition. - When the skipping exception is used in a suite setup, all tests in the suite are skipped.
- Command line option
--skipto unconditionally skip tests based on tags. Similar to--excludebut skipped tests are shown in logs/reports with a skip status and not dropped from execution altogether. - Command line option
--skiponfailureto 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
skhomuti commentedon Jul 30, 2020
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.
pekkaklarck commentedon Jul 30, 2020
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.
[-]New `SKIP` status for tests[/-][+]New `SKIP` status[/+]adiralashiva8 commentedon Sep 14, 2020
Skip Impacted Areas:
Following tools uses listener/api
Plugins/Notification
Tools:
robinmackaij commentedon Sep 14, 2020
I can see a case for both gray and yellow (or orange) based on the reason for skipping:
--skip TAGandrobot:skipoptions. 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.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.
Skip functionality (#3682)
pekkaklarck commentedon Sep 30, 2020
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:
Should skip be allowed in test teardown? If yes, what should happen if there has been a failure earlier?
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?
If a test is skipped, should possible teardown be executed?
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?
pekkaklarck commentedon Sep 30, 2020
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:
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.
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.
Teardowns won't be executed if a test is skipped explicitly with
Skipkeyword or otherwise. If a test fails and is marked skipped due to using--skiponfailure, teardown is executed normally.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.
robinmackaij commentedon Sep 30, 2020
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.
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.
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).
As with 1. I'd keep the FAIL result since that is the outcome of the test itself.
pekkaklarck commentedon Oct 1, 2020
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 Errorand the plannedRun Keyword And Warn On Errorthat 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.robinmackaij commentedon Oct 4, 2020
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.
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.
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.
7 remaining items
pekkaklarck commentedon Oct 18, 2020
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.SkipExecutionexception (see #3685 for other similarly exposed exceptions):Alternatively it's possible to create a custom exception that has a special
ROBOT_SKIP_EXECUTIONattribute set to a true value:Notice that the attribute name used to be
ROBOT_SKIP_ON_FAILUREbut it was changed toROBOT_SKIP_EXECUTIONin 685f78e.pekkaklarck commentedon Nov 25, 2020
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.
Enhance documentation related to test/suite statuses.
pekkaklarck commentedon Nov 25, 2020
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.pekkaklarck commentedon Nov 26, 2020
Run Keyword *problems explained in #3755 are fixed. Colors can be fine-tuned later so this issue can be considered done. 🎉Skip functionality (robotframework#3682)
Handle corner cases with skip. robotframework#3622
Skip fine-tuning. robotframework#3622
Test skip (robotframework#3622) with custom exception
Enhance documentation related to test/suite statuses.
Pratapreddy1188 commentedon Jul 12, 2023
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.