Skip to content

Commit 61f7c51

Browse files
committed
BuiltIn: add Skip If -keyword
1 parent 5142639 commit 61f7c51

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

atest/robot/running/skip.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ Skip Keyword
99
Skip with Library Keyword
1010
Check Test Case ${TEST NAME}
1111

12+
Skip If Keyword with True Condition
13+
Check Test Case ${TEST NAME}
14+
15+
Skip If Keyword with True Condition And Custom Message
16+
Check Test Case ${TEST NAME}
17+
18+
Skip If Keyword with False Condition
19+
Check Test Case ${TEST NAME}
20+
1221
Skip Keyword with Custom Message
1322
Check Test Case ${TEST NAME}
1423

atest/testdata/running/skip/skip.robot

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ Skip with Library Keyword
1515
Skip with Message Show must not got on
1616
Fail Should not be executed!
1717

18+
Skip If Keyword with True Condition
19+
[Documentation] SKIP 1 == 1
20+
Skip If 1 == 1
21+
22+
Skip If Keyword with True Condition And Custom Message
23+
[Documentation] SKIP Skipped with abandon.
24+
Skip If 1 == 1 Skipped with abandon.
25+
26+
Skip If Keyword with False Condition
27+
[Documentation] FAIL AssertionError
28+
Skip If 1 == 2
29+
Fail
30+
1831
Skip Keyword with Custom Message
1932
[Documentation] SKIP Skipped due to reasons
2033
Skip Skipped due to reasons

src/robot/libraries/BuiltIn.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,11 +2251,25 @@ def _get_suite_in_teardown(self, kwname):
22512251
class _Control(_BuiltInBase):
22522252

22532253
def skip(self, msg='Skipped with Skip keyword.'):
2254-
# TODO: docs
2255-
"""Skip execution of the rest of the current test/task.
2254+
"""Skips the rest of the current test.
2255+
2256+
Skips the remaining keywords in the current test and sets the given
2257+
message to the test. If the test has teardown, it will be executed.
22562258
"""
22572259
raise SkipExecution(msg)
22582260

2261+
def skip_if(self, condition, msg=None):
2262+
"""Skips the rest of the current test if the ``condition`` is True.
2263+
2264+
Skips the remaining keywords in the current test and sets the given
2265+
message to the test. If ``msg`` is not given, the ``condition`` will
2266+
be used as the message. If the test has teardown, it will be executed.
2267+
2268+
If the ``condition`` evaluates to False, does nothing.
2269+
"""
2270+
if self._is_true(condition):
2271+
raise SkipExecution(msg or condition)
2272+
22592273
def continue_for_loop(self):
22602274
"""Skips the current for loop iteration and continues from the next.
22612275

0 commit comments

Comments
 (0)