test-fullautomation / robotframework-testsuitesmanagement

Apache License 2.0
4 stars 2 forks source link

Redundant error messages #258

Closed HolQue closed 6 months ago

HolQue commented 8 months ago

Hi Son,

at a lot of positions you apply the same error message to both logger.error() and BuiltIn().unknown:

logger.error(self.sLoadedCfgError)
BuiltIn().unknown(self.sLoadedCfgError)

This causes unnecessary redundancy in console and in log file:

ERROR - Verification against JSON schema failed: 'Additional properties are not allowed ('IAMINVALID' was unexpected)'
          Please put the additional params into 'params': { 'global': {...}
UNKNOWN - Verification against JSON schema failed: 'Additional properties are not allowed ('IAMINVALID' was unexpected)'
          Please put the additional params into 'params': { 'global': {...}

This is confusing and makes no sense. It is possible to split available information in a more meaningful way. And a generic function should be used for logging UNKNOWN tests (and the same for failed tests).

Something like:

def log_unknown(error=None, impact=None):
    default_error  = "An unknown error happened."
    default_impact = "The test execution will be aborted now."
    if error is None:
        error = default_error
    else:
        error = f"{error}"
    if impact is None:
        impact = default_impact
    else:
        impact = f"{impact}"
    logger.error(error)
    BuiltIn().unknown(impact)

Now you can do this:

impact = "Unable to load the test configuration. The test execution will be aborted now."
log_unknown(self.sLoadedCfgError, impact)

In log file this looks much more plausible now:

ERROR - Verification against JSON schema failed: 'Additional properties are not allowed ('IAMINVALID' was unexpected)'
          Please put the additional params into 'params': { 'global': {...}
UNKNOWN - Unable to load the test configuration. The test execution will be aborted now.
namsonx commented 6 months ago

Hello Holger,

I pushed commit b3a65f87c05 to improve the method of logging error messages when loading the configuration failed. I also pushed commit bed8201f9 to update reference log for the Selftest.

Thank you, Son

HolQue commented 6 months ago

Retest successful. Issue can be closed.

test-fullautomation commented 6 months ago

Released with RobotFramework AIO 0.12.0