Skip to main content

robotframework-events

A Robot Framework listener that writes every suite, test, keyword, control structure and log message of a run as JSON Lines, while the run happens. Item ids are Robot Framework's own (s1-t2-k3), so events join with output.xml and link into log.html#<id>.

Requires Robot Framework 7.0 or newer and Python 3.10 or newer. Status: alpha.

pip install robotframework-events
robot --listener robotframework_events.Listener tests/                       # writes events.jsonl next to output.xml
robot --listener "robotframework_events.Listener;file=ev.jsonl;level=DEBUG" tests/

Listener arguments: file (NONE for no file), level (minimum message level, default INFO), messages, args, structures (each true/false, default true), max_text (default 4096) and flush (seconds between flushes of the file while the run goes on, default 0.1, so rfevents tail -f and editors that follow the file see the keyword that is running; 0 flushes after every test only).

Event format

One JSON object per line. Every event has v (format version), seq (1, 2, 3, ...), t (Unix time) and type: run.started, suite.started, test.started, step.started, message.logged, step.ended, test.ended, suite.ended, status.changed, resultfile.created, run.ended.

{"v":1,"seq":6,"t":1791581563.542,"type":"test.started","id":"s1-t1","parent":"s1","name":"Passing","longname":"Sample.Passing","lineno":6}
{"v":1,"seq":61,"t":1791581563.601,"type":"test.ended","id":"s1-t2","status":"FAIL","message":"1 != 2","elapsed":0.004}

The JSON Schema events-v1.schema.json is the reference.

Command line

rfevents tail -f results/events.jsonl          # follow a run in the terminal, keyword by keyword
rfevents tail --steps 2 --level INFO events.jsonl
rfevents convert output.xml -o events.jsonl    # events for a run recorded without the listener

tail prints suites, tests, steps down to --steps levels (default 1), log messages from --level (default WARN) and a summary. convert reads output.xml or output.json; steps then have no source or line number, which result files do not store.

Python API

from robotframework_events import RunState, add_callback, convert, read_events

state = RunState.from_events(read_events("events.jsonl"))  # also .jsonl.gz
print(state.status, state.counts())
for event in read_events("events.jsonl", follow=True):  # while the run writes it
    ...

events = list(convert("output.xml"))  # dicts, as the listener writes them
add_callback(fn)  # in-process consumers, e.g. robotcode's debugger

read_events gives typed events (robotframework_events.events). RunState holds the tree of suites, tests and steps with status, messages and times, and the running test and step.

Development

pip install -e .[dev]
ruff check . && ruff format --check . && mypy
pytest                 # format, options, schema, reader, CLI and conformance tests
pytest -m bench        # listener overhead
pytest -m e2e          # through robotcode's debugger (needs ../robotcode)

The conformance tests also run on Robot Framework's acceptance test data, found through RF_ATEST_DIR or at ../robotframework/atest/testdata, and are skipped when it is missing.

Licence

MIT

Metadata

Release files for robotframework-events 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for robotframework-events 0.5.0
File Size Uploaded Provenance
robotframework_events-0.5.0.tar.gz 33.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for robotframework-events 0.5.0
File Interpreter ABI Platform
robotframework_events-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.7 kB

Release files / robotframework_events-0.5.0.tar.gz

Download URL robotframework_events-0.5.0.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3313092b84886d2918497ad69723d7f05b74f6632ff4608c843a3ecd80ae43c6
BLAKE2b-256 checksum
How to use checksums
41941db8eabd1b67e5595849fc3c21c6e20cc554795cb4f9eb0943802e581616
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / robotframework_events-0.5.0-py3-none-any.whl

Download URL robotframework_events-0.5.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbe40fd27da40cceb05d0a3dfad8631caa8d6116acb20346da39177d4b3ba283
BLAKE2b-256 checksum
How to use checksums
5db31b9a6201876a06931b65cea9f36063656e91dd99ea4a1c58b5c87e0a661e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for robotframework-events 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page