FAQ
How do I run tests in parallel?
Install the parallel extra and use the --parallel flag:
How do I retry flaky tests?
Install the retry extra and set --retries:
How do I generate a JSON report?
Install the report-json extra and use --format json:
pip install "behave-runner[report-json]"
behave-runner run --format json --output reports/results.json features/
How do I use profiles?
Define profiles in pyproject.toml:
Then run:
What happens if an optional dependency is missing?
behave-runner prints a warning and falls back to a safe behavior. For
example, if behave-pool is missing, --parallel is ignored and the run
proceeds sequentially.
How do I watch files for changes?
Use the watch command:
It polls features/, steps/, environment.py, behave.ini, and
pyproject.toml and re-runs the suite on every change.
How do I list all scenarios without running them?
You can also export the list to JSON:
How do I find scenarios affected by code changes?
This uses behave-doctor to detect affected scenarios and runs them.
How do I record a browser session?
Install the record extra and run:
Where are the reports saved?
By default, reports are written to reports/. Use --output to change the
directory.
How do I embed behave-runner in my own Python script?
Use the public Python API:
from behave_runner.core.orchestrator import RunConfig, run
config = RunConfig(features=["features"], tags=["@smoke"])
exit_code = run(config)
See the Python API page for the full reference.