Reports and Output
By default behave prints a readable console report. For CI archives, dashboards, and trend tracking you need machine-readable or shareable formats. The -f / --format and -o / --output options select the formatter and where its output goes, and you can combine several pairs in one run.
Built-in Formatters
| Format | Output | Typical use |
|---|---|---|
pretty | Colored console tree of features, scenarios, and steps | Local development (default) |
progress | One character per step: . passed, F failed, S skipped | Fast console overview |
html | Single styled HTML file | Emailing results, static hosting |
json | Machine-readable JSON of the whole run | Custom pipelines, trend storage |
junit | JUnit XML | CI systems (Jenkins, GitLab, GitHub Actions) |
Writing Report Files
# console stays pretty; archives go to reports/
behave -f pretty -f html -o reports -f junit -o reports -f json -o reports
Every -f is paired with the next -o. Without -o, the report is written to standard output, so a second console-oriented format will overwrite your pretty output on the screen.
Reading the JSON Report
The JSON format mirrors the run: a list of features, each with scenarios, each with steps, including status, duration, and error text. A small script can turn it into a dashboard:
import json
with open("reports/report.json") as fh:
run = json.load(fh)
total = sum(len(s["steps"]) for f in run for s in f["scenarios"])
failed = sum(1 for f in run for s in f["scenarios"]
for st in s["steps"] if st["status"] == "failed")
print(f"{total} steps, {failed} failed")
Tips
- Put stable format/output settings in
behave.iniso every run archives its results. - Give the HTML file a predictable name if your CI links to it directly.
- Use the JUnit file for pass/fail gating and the JSON file for anything deeper.
Summary
Pair -f with -o to emit pretty, progress, HTML, JSON, and JUnit reports. Gate CI on the JUnit file and store the JSON for trend analysis; the HTML file is what humans read.