A pytest plugin for tracking test failures over multiple runs
Project description
pytest-failure-tracker
A pytest plugin for tracking test failures over multiple test runs, making it easier to identify flaky tests and frequently failing tests.
Installation
You can install pytest-failure-tracker
via pip:
pip install pytest-failure-tracker
Usage
To use the plugin, simply run pytest with the --track-failures
option:
pytest --track-failures
This will enable failure tracking for your test suite.
Features
Failure Tracking
The plugin tracks the following information for each test:
- Number of passes
- Number of failures
- Number of skips
- Timestamp of the last failure
- Traceback of the last failure
This data is stored in a JSON file (test_results.json
) in your project directory.
Summary Report
After each test run with --track-failures
enabled, the plugin will display a summary report in the terminal. This report includes:
- Total number of runs for each test
- Number of passes, failures, and skips
- Failure rate
- Timestamp of the last failure
- Traceback of the last failure
Persistent Storage
Test results are stored persistently, allowing you to track failures across multiple test runs and even across different sessions.
Example Output
============================= Test Failure Tracking Summary =============================
test_module.py::test_example:
Total runs: 10
Passes: 8
Failures: 2
Skips: 0
Failure rate: 20.00%
Last failure: 2024-07-16T14:30:00.123456
Last failure traceback:
File "test_module.py", line 15, in test_example
assert False, "This test intentionally fails sometimes"
AssertionError: This test intentionally fails sometimes
test_module.py::test_another_example:
Total runs: 10
Passes: 10
Failures: 0
Skips: 0
Failure rate: 0.00%
Configuration
Currently, the plugin doesn't require any additional configuration beyond the --track-failures
command-line option.
Limitations and Considerations
- The plugin treats parameterized tests as separate tests.
- There is currently no built-in way to reset or clear the tracking data. You can manually delete the
test_results.json
file to reset. - The plugin doesn't currently provide trend analysis over time.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
TODO: expand documentation with:
- More detailed examples of how to interpret the results
- Any known issues or edge cases
- A section on how to configure the plugin if you add any configuration options in the future
- A more detailed contribution guide if you want to encourage open-source contributions
- A changelog to track versions and updates
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_failure_tracker-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eed1d0629a51886701ce3829444f531d3cabd8686801b904e602f25a7f47a5f |
|
MD5 | a6593ee93546bb271c48612c71006bed |
|
BLAKE2b-256 | a8561c60100c0745da7e8723c73fed98d9abfb6bf6d12146d1f542bcade74781 |
Hashes for pytest_failure_tracker-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a66c2121f2f82aa640daf3a9193d75457a44e73515fd9aee19d357e10ceee20c |
|
MD5 | 43590c94663ee9936b0315dd86f1ce21 |
|
BLAKE2b-256 | cf1677b8a741cf76440176a91f8ebb240f7468b937917e91b9925b339fd2d57f |