pytest-split

0.11.0 · active · verified Mon Apr 06

Pytest plugin (version 0.11.0) which splits the test suite into equally sized sub-suites based on test execution time. This enables faster and more balanced parallelization of tests in CI/CD environments. It is actively maintained with a consistent release cadence, often including support for new Python and Pytest versions.

Warnings

Install

Quickstart

First, run pytest with the `--store-durations` flag to collect and save the execution times of your tests into a `.test_durations` file. This file should be committed to your repository. Then, use the `--splits N --group X` flags to divide your test suite into `N` groups and execute only the tests belonging to group `X`. This is typically used in CI/CD pipelines to parallelize test execution across multiple jobs.

# 1. Store test durations from a complete test suite run
pytest --store-durations

# This creates a .test_durations file in the current directory.
# It should be committed to your repository.

# 2. Split and run a specific group of tests (e.g., group 1 of 3 total splits)
pytest --splits 3 --group 1

view raw JSON →