0
votes

The way i raise errors from my keywords is by using the robot.api.logger class

def test_keyword():
    logger.error("Report error")

This creates an error line in the log.html file under the keyword but does not fail the keyword.

The way i fail a keyword is by raising exceptions.

def test_keyword():
    raise Exception("Not implemented")

This fails the keyword as well as the test case in which the keyword was called. But this also stops the further execution of the test case.

Is there any way i can fail a keyword without stopping the test case execution?

1
What is the sense of it? Keyword fails - test case fails. What is the reason of continuing the test execution? - Psytho
Can you explain in what way this would differ from your current logger.error() approach? From your description it seems that this does exactly what you want. - A. Kootstra
@Psytho : Consider a Test case with multiple verify/validate keywords within a test case. eg: verify_xyz_component_is_visible(), verify_total_displayed_for_column() etc. If my first keyword verify_xyz_component_is_visible() fails, i still would like to check the status of my second keyword verify_total_displayed_for_column() and keywords after that before stopping the execution of my test - GPT14
You can use Run Keyword And Ignore Error or Run Keyword And Continue On Failure or Run Keyword And Return Status. - Psytho
@A.Kootstra : Calling logger.error() from within a keyword logs the error but the status of that keyword is still PASS. What i want is to have a mechanism by which i can fail a keyword(change the status to FAIL without stopping the execution - GPT14

1 Answers

1
votes

From the documentation:

Library keywords report failures using exceptions, and it is possible to use special exceptions to tell the core framework that execution can continue regardless the failure.

When a test ends and there has been one or more continuable failure, the test will be marked failed. If there are more than one failure, all of them will be enumerated in the final error message:

Several failures occurred:

1) First error message.

2) Second error message ...

The way to signal this from test libraries is adding a special ROBOT_CONTINUE_ON_FAILURE attribute with True value to the exception used to communicate the failure. This is demonstrated by the examples below.

class MyContinuableError(RuntimeError):
    ROBOT_CONTINUE_ON_FAILURE = True