DEV.co
Open-Source Testing · tarpas

pytest-testmon

pytest-testmon is a pytest plugin that automatically detects which tests are affected by code changes and runs only those tests, speeding up CI/CD pipelines. It uses dependency tracking to map code changes to test coverage and re-executes the minimal necessary test suite.

Source: GitHub — github.com/tarpas/pytest-testmon
996
GitHub stars
78
Forks
Python
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorytarpas/pytest-testmon
Ownertarpas
Primary languagePython
LicenseMIT — OSI-approved
Stars996
Forks78
Open issues37
Latest releasev2.2.0 (2025-12-01)
Last updated2025-12-01
Sourcehttps://github.com/tarpas/pytest-testmon

What pytest-testmon is

A pytest plugin that builds and maintains a dependency database (.testmondata) tracking coverage relationships between source code and tests. On subsequent runs, it compares file modifications against this database to select affected tests, reducing full test suite execution time in development and CI workflows.

Quickstart

Get the pytest-testmon source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/tarpas/pytest-testmon.gitcd pytest-testmon# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Large Python projects with slow test suites

Teams with extensive test coverage and long feedback loops benefit from running only affected tests during development and in CI/CD, reducing cycle time from hours to minutes.

Continuous development with rapid iteration

Pairs well with pytest-watch for watch-mode testing. Developers make small changes and see immediate feedback on only the tests that matter, improving productivity.

CI/CD optimization for pull requests

Selectively run tests based on changed files in PR workflows, reducing infrastructure cost and providing faster feedback without sacrificing coverage.

Implementation considerations

  • Initial setup requires a baseline run (pytest --testmon) to build the dependency database; subsequent runs leverage this data to filter tests.
  • Dependency database (.testmondata) must be version-controlled or regenerated reliably in CI to avoid stale coverage maps across environments.
  • Accuracy depends on test coverage; uncovered code changes will not trigger test selection, so coverage gaps create blind spots.
  • Behavior with mocking, fixtures with side effects, and indirect dependencies may require tuning or manual exclusions; test the database against your codebase.
  • Best paired with pytest-watch in development; CI integration requires careful setup to ensure the database is fresh and consistent across branches.

When to avoid it — and what to weigh

  • Dynamic test discovery or highly coupled test suites — If tests depend on global state, fixtures with side effects, or tests are generated dynamically, the dependency database may miss affected tests or fail to track relationships accurately.
  • Small test suites that execute in seconds — Overhead of maintaining the dependency database and initial collection may exceed the time saved; simpler projects benefit from running the full suite.
  • Projects with minimal test coverage — If large portions of code are not covered by tests, testmon cannot correlate changes to tests and will skip many legitimate test selections, reducing its value.
  • Strict requirement for guaranteed coverage of all changes — Testmon's reliability depends on accurate coverage tracking in a dynamic language; if there is no tolerance for missed affected tests, full suite execution is safer.

License & commercial use

MIT License (OSI-compliant permissive license). Grants rights to use, modify, and distribute freely with minimal restrictions.

MIT License explicitly permits commercial use. No licensing fees, restrictions, or proprietary terms. Suitable for internal and commercial product development without vendor lock-in.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

No special security claims made. Dependency database is a local file; ensure .testmondata access is restricted if it contains sensitive coverage patterns. Uses standard pytest plugin architecture. Review upstream dependencies (pytest) for security advisories. No embedded credentials or remote telemetry evident.

Alternatives to consider

pytest-xdist

Parallelizes test execution across workers to reduce wall-clock time; does not filter tests by change, but complements testmon for full acceleration.

Bazel + aspect-bazel-lib (Python)

Build system-level change detection and test selection; more heavyweight but offers fine-grained dependency graphs across projects.

Custom git-based test selection (e.g., pre-commit hooks or CI scripts)

Parse git diffs and map files to tests via naming conventions or custom config; lightweight but requires manual maintenance and is less reliable for indirect dependencies.

Software development agency

Build on pytest-testmon with DEV.co software developers

Start with pytest-testmon for free. Install via pip, run pytest --testmon once to build your dependency database, then enjoy faster feedback loops. No vendor lock-in—MIT licensed, fully open-source.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

pytest-testmon FAQ

How reliable is testmon's affected-test selection?
Reliability depends on test coverage quality. The plugin tracks code-to-test dependencies via Python's coverage data; uncovered code changes and indirect dependencies (mocks, global state) may not trigger test selection. Recommend validating against your codebase before trusting fully in CI.
What happens if the .testmondata file is missing or corrupted?
Testmon gracefully falls back to running all tests, then rebuilds the database. No data loss; safe to delete .testmondata to reset state.
Can testmon be used in CI without developers running it locally?
Yes. Check .testmondata into version control (or regenerate in CI on baseline branch), then testmon will filter tests based on PR changes. Requires careful setup to ensure database freshness across branches.
Does testmon work with parametrized tests and fixtures?
Unknown without deeper testing. Coverage tracking should handle parametrized tests, but fixtures with complex side effects or indirect dependencies may not be tracked reliably. Test in your environment before relying on it.

Software development & web development with DEV.co

DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If pytest-testmon is part of your open-source testing roadmap, our team can implement, customize, migrate, and maintain it.

Ready to accelerate your Python test suite?

Start with pytest-testmon for free. Install via pip, run pytest --testmon once to build your dependency database, then enjoy faster feedback loops. No vendor lock-in—MIT licensed, fully open-source.