pytest-json-ctrf is a pytest plugin that generates test reports in the Common Test Report Format (CTRF) as a JSON file. This standard format allows for consistent reporting across various testing tools and frameworks, facilitating better analysis and integration with external systems like GitHub Actions for prettifying reports. The current version is 0.3.6, with releases tied to pytest compatibility and feature enhancements.
pip install pytest-json-ctrfNo compatibility data collected yet for this library.
First, create a simple test file (e.g., `test_example.py`). Then, run pytest from your terminal, specifying the `--ctrf` flag followed by the desired output filename. This will generate a JSON report in the Common Test Report Format in the specified file.
Always use `pytest --ctrf <your_report_file_name.json>`.
Ensure the plugin is installed (`pip install pytest-json-ctrf`) and activate it using the `--ctrf` command-line flag when running pytest. No explicit Python imports are typically needed in your test files for this plugin.
Rename test files and functions to follow pytest conventions (e.g., `test_my_feature.py`, `def test_functionality()`).
Ensure the plugin is installed by running `pip install pytest-json-ctrf` in the active Python environment. If already installed, verify the environment's `PATH` or virtual environment activation.
Verify that your pytest tests are actually running and producing reportable outcomes; an empty file often indicates no tests were executed or reported, or a prior error prevented report generation.
Confirm the `pytest --json-ctrf=report.json` command was executed successfully without errors, and check the current working directory or specified path to ensure the `report.json` file exists in the expected location after the test run.
Change the output directory to a location where the user has write permissions (e.g., the current working directory or a user-specific temporary directory), or adjust the file system permissions for the target directory.