You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed imports should fail suite they belong to #4774
We encountered follwoing scenario while using a custom library: (RF 6.0, Python 3.10.8)
When the initialization of the custom library fails, the test execution is continued until the first keyword provided by that library is used. The result is a rather misleading "No keyword with name 'XY' found.".
Here is a minimal example:
ExampleLib.py:
classExampleLib:
ROBOT_LIBRARY_SCOPE='SUITE'ROBOT_LISTENER_API_VERSION=3def__init__(self):
# do init stuffraiseException("something bad happened while doing init stuff")
defsayHello(self):
return"Hello World"
Example.robot:
*** Settings ***Library ExampleLib.py
*** Test Cases ***Test SayHello${res} = Set Variable "This is a String"
${res} = sayHello
Log To Console ${res}
Result:
It would be great to have the possibility to stop the test execution from within the custom libraries constructor.
Failing imports cause an error but they don't prevent executing a suite. There is, however, --exitonerror command line option that you can use to change the behavior. A problem with it is that it stops the whole execution which isn't always desirable.
I have lately been thinking that it would be better if a failing import would always fail the suite the import belongs to. In practice a failed import should be handled similarly as a failed suite setup; all tests in the suite should be marked failed without actually executing them. One big benefit of that design is that it would make implementing #4170 easier. As you can read from its comments, changing the behavior is pretty much a precondition to it. That issue is currently targeted for RF 7.0 and I assign this issue to it as well.
changed the title [-]Test Execution is continued eventhough custom library fails to initialize[/-][+]Failed imports should fail suite they belong to[/+]on May 31, 2023
Activity
pekkaklarck commentedon May 31, 2023
Failing imports cause an error but they don't prevent executing a suite. There is, however,
--exitonerrorcommand line option that you can use to change the behavior. A problem with it is that it stops the whole execution which isn't always desirable.I have lately been thinking that it would be better if a failing import would always fail the suite the import belongs to. In practice a failed import should be handled similarly as a failed suite setup; all tests in the suite should be marked failed without actually executing them. One big benefit of that design is that it would make implementing #4170 easier. As you can read from its comments, changing the behavior is pretty much a precondition to it. That issue is currently targeted for RF 7.0 and I assign this issue to it as well.
[-]Test Execution is continued eventhough custom library fails to initialize[/-][+]Failed imports should fail suite they belong to[/+]