Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Listeners cannot set timeouts #5350

Open
Open
@Lavinu

Description

@Lavinu

Description:
I want to use a Robot Framework listener to dynamically set the execution time for each test case during test execution. For example, in a CI scenario, I can define a total execution time, and during the Robot Framework run, dynamically adjust the remaining execution time for each test case.

However, it seems that there is currently no way to modify a test case's timeout parameter through a listener:

from robot import result, running
from testlogging import debug_log
logger = debug_log(__file__)

class TimeoutConfig:

    ROBOT_LISTENER_API_VERSION = 3

    def __init__(self, timeout: str):
        self.timeout = timeout
    def start_test(self, data: running.TestCase, result: result.TestSuite):
        logger.info('ROBOT LISTENER: Test Case {} has timeout {}', data.name, data.timeout)
        data.timeout = self.timeout
        logger.info('ROBOT LISTENER: Test Case {} has timeout {}', data.name, data.timeout)

Test case:

Suite Teardown      Suite Teardown

*** Test Cases ***
Log Hello World
    [Timeout]    5
    [Teardown]    Testcase Teardown
    Sleep    20

The console shows data.timout output was modified but the robot report shows the timeout still keep original.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions