Example Python Robot framework test :
*** Keywords ***
Calculate
[Arguments] ${expression} ${expected}
Push buttons C${expression}=
Result should be ${expected}
Calculation should fail
[Arguments] ${expression} ${expected}
${error} = Should cause error C${expression}=
Should be equal ${expected} ${error} # Using `BuiltIn` keyword
Here is the sample behind the scenes code:
class CalculatorLibrary(object):
"""Test library for testing *Calculator* business logic.
Interacts with the calculator directly using its ``push`` method.
"""
**is_skip = False**
def result_should_be(self, expected):
"""Verifies that the current result is ``expected``.
Example:
| Push Buttons | 1 + 2 = |
| Result Should Be | 3 |
"""
if self._result != expected:
**is_skip = True**
**NOW MARK THE TEST AS SKIPPED**
raise AssertionError('%s != %s' % (self._result, expected))
def should_cause_error(self, expression):
"""Verifies that calculating the given ``expression`` causes an error.
The error message is returned and can be verified using, for example,
`Should Be Equal` or other keywords in `BuiltIn` library.
Examples:
| Should Cause Error | invalid | |
| ${error} = | Should Cause Error | 1 / 0 |
| Should Be Equal | ${error} | Division by zero. |
"""
try:
self.push_buttons(expression)
except Exception as err:
return str(err)
else:
raise AssertionError("'%s' should have caused an error."
% expression)
I would like to skip a Robot test at runtime within Python code instead of using the Robot Framework keyword. The use case could be if we would like to skip tests in case a certain component for example calulator is down in the test environment