I’m trying to use BuiltIn.run_keyword() to execute and highlight threshold checking within a custom library. I need execution to continue if there is a failure, and thus I’m raising robot.api.ContinuableFailure. Here is a small example.
MyLibrary.py:
def __init__(self) -> None:
self.ROBOT_LIBRARY_LISTENER = self
self.output_directory = Path('.')
def _start_suite(self, name, _):
try:
self.robot_builtin = BuiltIn()
except:
warn('_start_suite listener function failed to execute')
def _check(self, pattern:str='Value Error of 1 should be less than 2'):
# self.robot_builtin.run_keyword_and_continue_on_failure(pattern) # same problem
self.robot_builtin.run_keyword(pattern)
@keyword('${check_name} of ${value} should be less than ${threshold}')
def _check_less_than(self, check_name, value, threshold):
print(f'value: {value} should be less than {threshold}')
if value > threshold:
raise ContinuableFailure('Threshold Exceeded')
def my_keyword(self):
self._check('Value of 3 should be less than 2')
info('this should be printed regardless')
Unfortunately the execution stops after the first error is raised, and the info() text is not printed in the above example. Maybe I am not using this exception correctly but I would really like to use this kind of _check() function in a for loop to check bounds on a number of values within my custom library’s keywords, and get all the way through the loop before exiting the keyword.
Is this possible?