robotframework icon indicating copy to clipboard operation
robotframework copied to clipboard

Run Keyword and Ignore Error doesn't handle logging w/ --exitonerror

Open MrMino opened this issue 3 years ago • 2 comments

Looks like Run keyword and ignore error does not shield from the ERROR log messages, and tests still fail with --exitonerror flag on. Shouldn't it ignore the logs too?


Repro code:

# kw.py
import logging

def mykw(msg):
    logging.error(msg)
*** Settings ***
Library  kw.py

*** Test Case ***
Test
    Run Keyword and ignore error   mykw   error msg

Test2
    Log to Console   This should not fail

Run with: robot --exitonerror test.robot


Log:

image

MrMino avatar Mar 10 '21 16:03 MrMino

Run Keyword And Ignore Error catches failures caused by keywords but doesn't do anything to error messages. The --exitonerror option was actually introduced to make failed library imports etc. visible and back then explicitly logging error messages wasn't even supported. Execution stopping in this case is thus not even a planned feature.

I guess Run Keyword And Ignore Error could be enhanced to silence also WARN and ERROR messages, but I'm slightly worried could that in some cases also hide real problems. Since you need to explicitly use that keyword I guess that's ok. Anyway, I don't consider this too high priority.

The biggest problem I see here is that the keyword has "Error" in its name when we generally use "Failure" when talking about failing keywords. Keyword named like this not handling error messages is certainly somewhat strange. I doubt renaming the keyword is a good idea, especially when the plan is to sometime in the future add native TRY/EXCEPT functionality.

pekkaklarck avatar Mar 10 '21 17:03 pekkaklarck

With the TRY/EXCEPT functionality in RF 6.1.1, when an error is caught, it seems that the calling Test/Task is still treated as failed:

image

manosnoam avatar Dec 17 '23 18:12 manosnoam