Skip to main content

TestLedger — Test Estate Balance Sheet

CI License: MIT Python 3.11+ GitHub Action

Your test suite is a portfolio. TestLedger is its balance sheet. Every automated test carries a cost (CI minutes, reruns, engineer triage, maintenance churn) and produces a return (regressions caught before production). TestLedger books both from the data you already have — CI results and git history — and produces a one-page Quality Investment Memo that a VP of Engineering or CFO can act on.

Most tooling in this space stops at "which tests are flaky". TestLedger answers the question leaders actually ask: which tests are worth what we pay for them, and where should the next dollar of QE effort go?


What you get

Artefact Audience What it says
memo.md / memo.html VP Eng, CFO, Director of QE Bottom line, reallocation recommendation, where the money goes, top liabilities/assets, assumptions
balance_sheet.json QE leads Assets vs. liabilities per test, by pyramid layer, by suite
income_statement.json Finance / QE leads Cost by category (CI, reruns, triage, maintenance) vs. value delivered
writeoffs.json Team leads The action list: retire / demote / fix / quarantine, each with a reason
ai_liabilities.json QE governance AI-generated tests that fail mutation-score or assertion-density thresholds ("test theater")
ledger.json Dashboards The full book — diff it quarter over quarter
PR comment / job summary Engineers Compact table posted by the GitHub Action

See a real one: sample memo (Markdown) · HTML version · write-off list — generated from the built-in demo in under a second.

Quick start (any OS — Windows, macOS, Linux)

pip install git+https://github.com/surkuar/testledger.git
# or, from a clone:  pip install -e .

# 1. Try the built-in demo (fake repo, 12 weeks of CI history, reruns, a real regression, an AI-written test)
python examples/generate_demo.py demo-estate
cd demo-estate
testledger analyze --config testledger.yml --reports . --mutation mutation.json --out reports
testledger memo reports            # print the memo
start reports/memo.html            # Windows  (macOS: open, Linux: xdg-open)

# 2. On your own repo
testledger init                    # writes testledger.yml with documented defaults
testledger analyze --config testledger.yml --reports path/to/ci-reports --out testledger-out

Local report folder convention

TestLedger needs to know which CI runs re-executed the same commit — that is how flakiness is detected without any test-framework changes. For local folders, name each run directory:

ci-reports/
  20260915-066b939951-attempt1/TEST-results.xml      # <YYYYMMDD>[THHMM]-<sha>-attempt<N>
  20260915-066b939951-attempt2/TEST-results.xml      #   same SHA, attempt 2 => a rerun
  20260917-17f9d0b9e0-attempt1/cucumber.json

When you use the GitHub Actions or Jenkins ingesters this metadata comes from the CI API automatically.

Inputs supported (v1)

Source How Notes
JUnit XML (Surefire, Gradle, pytest, Jest, …) sources.junit_globs universal baseline
TestNG testng-results.xml sources.junit_globs auto-detected
Cucumber JSON (jvm / ruby / js) sources.cucumber_globs scenario = test, outline rows distinct
Git history sources.git_repo maintenance churn on test files; fix-commit detection for value credit
GitHub Actions sources.github run history + artifacts via REST API, run_attempt = rerun
Jenkins sources.jenkins build history + testReport JSON; same SHA in consecutive builds = rerun
Mutation reports --mutation PIT XML, Stryker JSON, or {file: score} JSON

How it works (short version)

flowchart LR
  A[JUnit / TestNG XML] --> N[Normalise to TestRun]
  B[Cucumber JSON] --> N
  C[GitHub Actions API] --> N
  D[Jenkins API] --> N
  G[git log] --> H[Churn + fix commits]
  S[Test sources] --> AI[AI provenance + assertion density]
  M[Mutation report] --> AI
  N --> E[Ledger engine]
  H --> E
  AI --> E
  E --> R[Balance sheet · Income statement · Write-offs · Memo]

Debits (cost) per test: CI minutes × rate · rerun minutes · flaky false-alarms × triage minutes × engineer rate · test-file lines changed × maintenance minutes × engineer rate.

Credits (value) per test: a genuine first-attempt failure (not cleared by a same-SHA rerun) followed within 3 days by a product-code commit that looks like a fix, valued at your organisation's cost of a production defect.

Verdicts: quarantine (flake ≥ 30 %) · retire (no catches, net negative, cost above floor) · demote (UI test whose cost-per-catch is ≥ 3× the service-layer median) · fix (valuable but flaky or slow) · asset · hold.

Every rate and threshold lives in testledger.yml and is printed on the memo so finance can challenge it. Full derivation: docs/methodology.md. Architecture and flowcharts: docs/design.md.

Use as a GitHub Action

# .github/workflows/testledger.yml
name: TestLedger
on:
  schedule: [{ cron: "0 6 * * 1" }]   # weekly memo
  pull_request:
permissions:
  contents: read
  actions: read
  pull-requests: write
jobs:
  ledger:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }           # full history for churn / fix detection
      - uses: surkuar/testledger@v0.1.0
        with:
          config: testledger.yml
          reports: build/test-results      # or leave empty and configure sources.github
          fail-on-quarantine: "false"

The action uploads all reports as an artifact, appends the memo to the job summary, and keeps one live comment on each PR.

Configuration

testledger init writes a fully commented file. The important parts:

org_name: Acme Commerce
window_days: 90
rates:
  engineer_hourly_usd: 75        # fully loaded
  ci_minute_usd: 0.008
  triage_minutes_per_false_alarm: 18
  maintenance_minutes_per_line: 1.5
  regression_value_usd: 2000     # cost of one escaped defect — your number
thresholds:
  quarantine_flake_rate: 0.30
  fix_flake_rate: 0.10
  slow_test_seconds: 60
  demote_layer_cost_ratio: 3.0
  retire_min_cost_usd: 25
  ai_min_mutation_score: 0.5
  ai_min_assertion_density: 0.8
sources:
  junit_globs: ["**/surefire-reports/*.xml", "**/TEST-*.xml"]
  cucumber_globs: ["**/cucumber*.json"]
  git_repo: "."
  github: { repo: "acme/shop", workflow: "ci.yml", token_env: "GITHUB_TOKEN", max_runs: 200 }
  jenkins: { url: "https://ci.acme.com", job: "shop/main", user_env: "JENKINS_USER", token_env: "JENKINS_TOKEN" }

Why this exists

Engineering leaders are routinely told to present automation "as risk-adjusted ROI" — but nothing computes it from real data. Flaky-test tools price flakes; ROI calculators take hand-typed guesses; the test-portfolio idea lives in blog posts. TestLedger closes that gap: it is the first open-source tool that treats a test estate as a managed portfolio with per-test P&L, a balance sheet, and an executive memo — framework-agnostic, CI-agnostic, and runnable in two minutes on any OS.

It was built by a QE leader for QE leaders. If you run a quality organisation and need to defend (or reallocate) a testing budget, this is the number you were missing.

Development

pip install -e ".[dev]"
pytest                     # 25 tests, offline (CI APIs stubbed; git tests use a throwaway repo)
ruff check src tests

Roadmap

  • GitLab CI and Azure DevOps ingesters
  • Code-ownership join (CODEOWNERS) so the memo is grouped by team
  • Quarter-over-quarter diff (testledger diff q3.json q4.json)
  • Optional LLM narrative for the memo (opt-in, local or API)
  • Web dashboard reading ledger.json

License

MIT © Suresh Babu. See LICENSE.

Metadata

Release files for testledger 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for testledger 0.1.0
File Size Uploaded Provenance Actions
testledger-0.1.0.tar.gz 40.7 kB With provenance Details for testledger-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for testledger 0.1.0
File Interpreter ABI Platform Actions
testledger-0.1.0-py3-none-any.whl Python 3 none any Details for testledger-0.1.0-py3-none-any.whl

Total release size: 78.7 kB

Release files / testledger-0.1.0.tar.gz

Download URL testledger-0.1.0.tar.gz
Size 40.7 kB
Tags Source
SHA-256 checksum
How to use checksums
009e309c79e0a19d1c11973e558de12b1085ac6534d10c685b2917543c7df4b1
BLAKE2b-256 checksum
How to use checksums
28f5ae2bc450f9b6e34adb0c2f5a91b7337bb5f0c823cf03116827d4d5500bcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / testledger-0.1.0-py3-none-any.whl

Download URL testledger-0.1.0-py3-none-any.whl
Size 37.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ea6e5389774fa195dc3f7f392edfe821cdb7f489d9181ab0fe71b57b5e6431c
BLAKE2b-256 checksum
How to use checksums
332c36fa2d289286ce30b8ed7a68004746780e95e088d4112a511e481119d932
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for testledger 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for testledger-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page