Skip to main content

Pytest plugin implementing flaky test failure detection and classification.

Project description

Pytest FlakeFighters

Project Status: Active – The project has reached a stable, usable state and is being actively developed. PyPI version Python versions Test status codecov Documentation Status GitHub License

Pytest plugin implementing flaky test failure detection and classification.

Read more about flaky tests here.

Features

  • Implements the DeFlaker algorithm for pytest
  • Implements two traceback-matching classifiers from Alshammari et al. (2024).
  • Implements a novel coverage-independence classifier that classifies tests as flaky if they fail independently of passing test cases that exercise overlapping code.
  • Optionally rerun flaky failures
  • Output results to JSON, HTML, or JUnitXML
  • Save test outcome history to a remote or local database

Installation

You can install "pytest-flakefighters" by cloning this repo and running pip install . from the root directory. If you intend to develop the plugin, run pip install -e .[dev] instead.

We eventually intend to distribute our tool on PyPI.

Usage

FlakeFighter is intended to run on git repositories that have test suites runnable with pytest. Once you have installed FlakeFighter, you can run it from the root directory of your repo simply by running pytest in your usual way. FlakeFighter has the following arguments.

  --target-commit=TARGET_COMMIT
                        The target (newer) commit hash. Defaults to HEAD (the most recent commit).
  --source-commit=SOURCE_COMMIT
                        The source (older) commit hash. Defaults to HEAD^ (the previous commit to target).
  --repo=REPO_ROOT      The commit hash to compare against.
  --suppress-flaky-failures-exit-code
                        Return OK exit code if the only failures are flaky failures.
  --no-save             Do not save this run to the database of previous flakefighters runs.
  -M LOAD_MAX_RUNS, --load-max-runs=LOAD_MAX_RUNS
                        The maximum number of previous runs to consider.
  -D DATABASE_URL, --database-url=DATABASE_URL
                        The database URL. Defaults to 'flakefighter.db' in current working directory.
  --store-max-runs=STORE_MAX_RUNS
                        The maximum number of previous flakefighters runs to store. Default is to store all.
  --time-immemorial=TIME_IMMEMORIAL
                        How long to store flakefighters runs for, specified as `days:hours:minutes`. E.g. to store
                        tests for one week, use 7:0:0.

Contributing

Contributions are very welcome. Tests can be run with pytest, please ensure the coverage at least stays the same before you submit a pull request.

Flake Fighters

Our plugin is made up of a collection of heuristics that come together to help inform whether a test failure is genuine or flaky. These come in two "flavours": those which run live after each test, and those which run at the end of the entire test suite. Both extend the base class FlakeFighter and implement the flaky_failure method, which returns True if the test is deemed to be flaky.

Issues

If you encounter any problems, please file an issue along with a detailed description.


This pytest plugin was generated with Cookiecutter along with @hackebrot's cookiecutter-pytest-plugin template.

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

pytest_flakefighters-0.3.1.tar.gz (204.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_flakefighters-0.3.1-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_flakefighters-0.3.1.tar.gz.

File metadata

  • Download URL: pytest_flakefighters-0.3.1.tar.gz
  • Upload date:
  • Size: 204.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_flakefighters-0.3.1.tar.gz
Algorithm Hash digest
SHA256 03ca3618ce274767e2b0d2dfdb9e76619115b5c967950074def8e220afc1704f
MD5 c230737648d27dff7976fb67aa13b56f
BLAKE2b-256 17b08bd04693708519b63845c50a64cc0639bb1df92c3beeb3cbdf5319fcf5e4

See more details on using hashes here.

File details

Details for the file pytest_flakefighters-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_flakefighters-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b31d4e1ef4e4ed982df90352c5da7b7e016f1539594a470b096d092bca38b60
MD5 13971c24bcb5963f50575cb61ffc11f7
BLAKE2b-256 6c975c47efb6bb137c35679b2f1454e81adb3dbda083220929da5c6706c84fbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page