Allure Robot Framework
raw JSON → 2.15.3 verified Fri Apr 17 auth: no python
Allure Robot Framework integration provides a listener for Robot Framework that automatically collects test results and converts them into Allure's intermediate JSON format. This allows for generating rich, interactive test reports with detailed information on test execution. The current version is 2.15.3, and it follows the release cadence of the broader allure-python project, which is generally active with frequent updates.
pip install allure-robotframework Common errors
error FileNotFoundError: [Errno 2] No such file or directory: 'allure' ↓
cause The `allure` command-line tool is not installed or not in your system's PATH.
fix
Install the Allure command-line tool globally. Example:
npm install -g allure-commandline. error ModuleNotFoundError: No module named 'allure_robotframework' ↓
cause The `allure-robotframework` Python package is not installed in your active Python environment.
fix
Install the package:
pip install allure-robotframework. error Listener 'allure_robotframework' does not exist. ↓
cause This error occurs during Robot Framework execution if `allure-robotframework` is not installed, or if there's a typo in the listener name, or if the package is installed in a different Python environment than the one running Robot Framework.
fix
Ensure
pip install allure-robotframework has been run and verify the correct spelling: robot --listener allure_robotframework your_tests.robot. error [ ERROR ] Parsing 'your_keywords.robot' failed: File or directory to import does not exist. (allure_robotframework.library_api) ↓
cause When using `Library allure_robotframework.library_api` in your Robot file, this indicates that the library API cannot be found by Robot Framework.
fix
Confirm that
allure-robotframework is installed and accessible to your Robot Framework environment. Ensure the casing is correct: Library allure_robotframework.library_api. Warnings
gotcha The Allure command-line tool (`allure`) is not automatically installed with `allure-robotframework`. It is crucial for generating the final HTML report from the raw JSON results. ↓
fix Install the Allure command-line tool separately. For example: `npm install -g allure-commandline` (Node.js required) or `brew install allure` (macOS).
gotcha The `allure-results` directory contains raw JSON data from test execution, not the human-readable report. These files must be processed by the Allure command-line tool to create the final HTML report. ↓
fix After running tests, execute `allure generate allure-results -o allure-report --clean` (replace `allure-report` with your desired output directory).
gotcha When running Robot Framework, ensure the Allure listener is correctly specified with `--listener allure_robotframework`. Typos or incorrect capitalization will prevent results from being collected. ↓
fix Always use the exact listener name: `robot --listener allure_robotframework your_tests.robot`.
breaking Older versions of `allure-robotframework` might not be compatible with newer versions of Robot Framework (e.g., Robot Framework 4.0 removed deprecated APIs which could break older listeners). ↓
fix Always use a compatible version. Refer to the `allure-python` GitHub page for current compatibility with Robot Framework versions. Upgrade `allure-robotframework` to the latest stable release for best compatibility.
Install
npm install -g allure-commandline # or brew install allure on macOS Imports
- step
from allure_robotframework.library_api import step - attach
from allure_robotframework.library_api import attach
Quickstart
import os
import subprocess
# 1. Create a dummy Robot Framework test file
robot_file_content = """
*** Settings ***
Library OperatingSystem
Library allure_robotframework.library_api
*** Test Cases ***
Simple Allure Robot Test
Log To Console Starting Allure Robot Test
allure_robotframework.library_api.step This is an Allure step
Create File test_attachment.txt Some attachment content
allure_robotframework.library_api.attach test_attachment.txt
Log To Console Test completed!
"""
robot_file_path = "example.robot"
with open(robot_file_path, 'w') as f:
f.write(robot_file_content)
print(f"Created {robot_file_path}")
# 2. Run Robot Framework tests with the Allure listener
print("\n--- Running Robot Framework tests ---")
# This command executes Robot Framework, using allure-robotframework as a listener.
# It generates raw Allure results in the 'allure-results' directory.
try:
subprocess.run(
["robot", "--listener", "allure_robotframework", robot_file_path],
check=True,
capture_output=True,
text=True
)
print("Robot Framework tests executed successfully. Allure results generated in 'allure-results'.")
except subprocess.CalledProcessError as e:
print(f"Error running Robot Framework tests: {e}")
print(f"Stdout:\n{e.stdout}")
print(f"Stderr:\n{e.stderr}")
print("Please ensure 'robotframework' and 'allure-robotframework' are installed.")
exit(1)
except FileNotFoundError:
print("Error: 'robot' command not found. Please install Robot Framework.")
exit(1)
# 3. Generate the Allure report
print("\n--- Generating Allure report ---")
# This command processes the raw results and creates a human-readable HTML report.
# It requires the 'allure-commandline' tool to be installed.
report_dir = "allure-report"
try:
subprocess.run(
["allure", "generate", "allure-results", "-o", report_dir, "--clean"],
check=True,
capture_output=True,
text=True
)
print(f"Allure report generated successfully in '{report_dir}'.")
print(f"To view the report, open '{os.path.abspath(report_dir)}/index.html' in your browser, or run 'allure open {report_dir}'.")
except FileNotFoundError:
print("\nError: 'allure' command not found.")
print("Please install the Allure command-line tool. See https://docs.qameta.io/allure/#_install_a_commandline for instructions.")
exit(1)
except subprocess.CalledProcessError as e:
print(f"Error generating Allure report: {e}")
print(f"Stdout:\n{e.stdout}")
print(f"Stderr:\n{e.stderr}")
exit(1)
# Optional cleanup:
# os.remove(robot_file_path)
# os.remove("test_attachment.txt")
# import shutil
# shutil.rmtree("allure-results", ignore_errors=True)
# shutil.rmtree(report_dir, ignore_errors=True)