pytest-json-report is a pytest plugin that generates a comprehensive JSON report of your test results. It provides detailed information on test outcomes, collected items, and environment details, useful for integration with CI/CD systems or custom reporting tools. The current version is 1.5.0, with minor releases occurring every few months to address bugs and add features.
pip install pytest-json-reportNo compatibility data collected yet for this library.
Create a `test_example.py` file with some tests, then run `pytest --json-report` from your terminal. This command will execute your tests and generate a `report.json` file in your current working directory containing the test results and a summary.
Ensure your project uses Python 3.7-3.10 and pytest 3.7-7.0 to use pytest-json-report v1.5.0 and newer.
Always include `--json-report` when running pytest or configure it in `pytest.ini`.
If parsing reports from older versions, be aware that `collected` and `deselected` counts might be missing or inaccurate. Update to v1.5.0 or newer for the most accurate and complete summary data.
Use `--json-report-file=/path/to/your/report.json` to specify the output path. Use `--json-report-verbosity=0|1|2` (since v1.4.0) to control terminal output verbosity (0=silent, 1=summary only, 2=verbose).
Install the plugin using pip: `pip install pytest-json-report`
Use the `--json-report-file` option to specify an output file: `pytest --json-report --json-report-file=report.json`
Specify a file name for the report: `pytest --json-report --json-report-file=output.json`
Ensure that your tests complete without errors that might corrupt the report file and that no other process or output is inadvertently writing to the specified report file path.