Skip to main content

Pytest plugin to keep a history of your pytest runs

Project description

pytest-history

Pytest plugin to keep history of your pytest runs

Checks Master License Supported Python Versions PyPi Package

Overview

pytest-history enables the tracking of test statuses and other metadata across multiple test runs, providing additional insights into test behavior.

Initially, this plugin was developed specifically to identify potentially flaky tests (approximately 200) within a test suite containing over 1000 tests, where various tests exhibited inconsistent behavior by failing on alternate runs.

Purpose

  • Tracking Test History: Capturing and storing historical test results, encompassing pass, fail, and other pertinent metadata.
  • Identifying Flaky Tests: Enabling the identification of flaky tests by scrutinizing historical data, detecting irregularities or recurring patterns in test outcomes.
  • Facilitating Debugging: Offering developers and testers insights into test stability, thereby assisting in debugging efforts and enhancing overall test reliability.

Usage

  1. Install the plugin using pip install pytest-history.
  2. Utilize the historical data stored in the .test-results.db SQLite database using either the pytest-history CLI or an SQLite client.

CLI

The pytest-history command utilizes a SQLite database (default: .test-results.db) to provide analysis and information about past test runs and their results. It offers two main subcommands: list and flakes.

Subcommands

list

  • pytest-history list offers insights into historical data and provides two additional subcommands: results and runs.
subcommand results
  • pytest-history list results <id>: Lists historic test results for a specific test run identified by its ID.
subcommand runs
  • pytest-history list runs: Lists historic test runs.

flakes

  • pytest-history flakes: Lists all flaky tests identified in the test suite.

Usage

pytest-history [options] <subcommand> [suboptions]

options
    -h, --help: Show the help message and exit.
    --db DB: Specify the database to be used for analyzing data (default: .test-results.db).

Examples

List historic test runs

pytest-history list runs

List historic test results for a specific run

pytest-history list results <id>

List all flaky tests

pytest-history flakes

Example Queries

Example: To find flaky tests between two distinct test runs, execute the following SQL query:

SELECT t1.testcase, t1.test_run, t2.test_run, t1.outcome, t2.outcome
FROM "test.results" t1
         JOIN "test.results" t2 on t1.testcase = t2.testcase AND (t1.test_run = 1 AND t2.test_run = 2)
WHERE (t1.outcome = 'passed' AND t2.outcome = 'failed')
   OR (t1.outcome = 'failed' AND t2.outcome = 'passed')
GROUP BY t1.testcase
ORDER BY t1.testcase;

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_history-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

pytest_history-0.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_history-0.2.0.tar.gz.

File metadata

  • Download URL: pytest_history-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.5.4-76060504-generic

File hashes

Hashes for pytest_history-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f88e199664750091e1192a1546c0086b3f38e33350ca5645833ac0daaa0a87f4
MD5 58d028d11ad556813561516710d64721
BLAKE2b-256 3a36fa3450731023b15dae6f54cff7b5b5401489ee61595f85901249581c426c

See more details on using hashes here.

File details

Details for the file pytest_history-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_history-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.5.4-76060504-generic

File hashes

Hashes for pytest_history-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31a59426b44b83543936f8a60c49d58f96b03c6c0bb9353b9bd619fff477244c
MD5 bffde4bd09ec8a70ade518b554225e7e
BLAKE2b-256 6159c0b5ab8c076ed797cfe4440f58a036ba7fd8d55cfa51b858dfb7709f1654

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