Robot Framework RetryFailed Listener
robotframework-retryfailed is a Robot Framework listener that enables automatic retrying of failed tests or tasks based on specific tags. It integrates directly with Robot Framework's execution, providing in-place retries for individual failing tests without requiring a separate re-execution command. The current version is 0.2.0, released in October 2022, and its release cadence appears infrequent.
Warnings
- gotcha The listener is triggered via command-line arguments to `robot`, not by importing a class in a Python file. Ensure the listener name `RetryFailed` is correctly spelled and followed by a colon for arguments (e.g., `RetryFailed:2`).
- gotcha Users often confuse this listener with Robot Framework's built-in `Wait Until Keyword Succeeds` keyword (for individual keywords) or the `--rerunfailed` command-line option (for re-executing failed tests from a previous run). `robotframework-retryfailed` offers in-place retries for entire tests or tasks during a single execution run.
- gotcha There are open issues regarding potential conflicts with Robot Framework's `exitonfailure` option, which might cause unexpected behavior when combined with `robotframework-retryfailed`.
- gotcha An open issue on GitHub reports that the listener might not retry 'Setup' sections (Suite Setup or Test Setup), only the test body itself. Also, issues exist where the first test case in a file might run twice, even if it passes.
- breaking The project's GitHub repository currently shows no explicit 'Releases' section, despite the package being available on PyPI. This can make tracking structured release notes or breaking changes between versions difficult.
Install
-
pip install robotframework-retryfailed
Imports
- RetryFailed
robot --listener RetryFailed <your_suite.robot>
- RetryFailed with arguments
robot --listener RetryFailed:1 <your_suite.robot>
Quickstart
import os
# Create a dummy Robot Framework test file
robot_file_content = '''
*** Settings ***
Library OperatingSystem
*** Test Cases ***
Example Failing Test
[Tags] test:retry(2)
Fail If True This test is designed to fail and retry
'''.strip()
with open('my_tests.robot', 'w') as f:
f.write(robot_file_content)
# Run Robot Framework with the RetryFailed listener
# For demonstration, we'll just print the command
# In a real scenario, you'd run this via subprocess or directly in your shell
robot_command = f"robot --listener RetryFailed:2 my_tests.robot"
print(f"To run the example, execute:\n{robot_command}")
# Expected outcome: The test 'Example Failing Test' will fail, be retried twice, and ultimately still fail if 'Fail If True' is never satisfied.
# The final report will show retries occurred.