Skip to content

Failed imports should fail suite they belong to #4774

Description

@JonasSchares

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:

class ExampleLib:
    ROBOT_LIBRARY_SCOPE = 'SUITE'
    ROBOT_LISTENER_API_VERSION = 3

    def __init__(self):
        # do init stuff
        raise Exception("something bad happened while doing init stuff")

    def sayHello(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:
Result

It would be great to have the possibility to stop the test execution from within the custom libraries constructor.

Activity

  1. pekkaklarck commented on May 31, 2023

    @pekkaklarck
    Member

    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.

  2. 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
  3. added this to the v7.0 milestone on May 31, 2023
  4. modified the milestones: v7.0, v8.0 on Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions