From 80c3ff2aee38c8f0e9bdb50d325fe267d0e1d1fb Mon Sep 17 00:00:00 2001 From: Jeffrey 'Alex' Clark Date: Thu, 12 Mar 2026 12:42:15 -0400 Subject: [PATCH] PYTHON-5753 Add just recipes for running coverage tests locally (#2727) --- .gitignore | 1 + CONTRIBUTING.md | 1 + justfile | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index cb4940a55..f69f27404 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ test/lambda/*.json xunit-results/ coverage.xml server.log +.coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4eafeddc..86c5e6455 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -205,6 +205,7 @@ the pages will re-render and the browser will automatically refresh. and the `` to test a full module. For example: `just test test/test_change_stream.py::TestUnifiedChangeStreamsErrors::test_change_stream_errors_on_ElectionInProgress`. - Use the `-k` argument to select tests by pattern. +- Run `just test-coverage` to run tests with coverage and display a report. After running tests with coverage, use `just coverage-html` to generate an HTML report in `htmlcov/index.html`. ## Running tests that require secrets, services, or other configuration diff --git a/justfile b/justfile index 78f48c2c7..3a8e216db 100644 --- a/justfile +++ b/justfile @@ -82,6 +82,25 @@ teardown-tests: integration-tests: bash integration_tests/run.sh +[group('test')] +test-coverage *args="": + just setup-tests --cov + just run-tests {{args}} + +[group('coverage')] +coverage-report: + uv tool run --with "coverage[toml]" coverage report + +[group('coverage')] +coverage-html: + uv tool run --with "coverage[toml]" coverage html + @echo "Coverage report generated in htmlcov/index.html" + +[group('coverage')] +coverage-xml: + uv tool run --with "coverage[toml]" coverage xml + @echo "Coverage report generated in coverage.xml" + [group('server')] run-server *args="": bash .evergreen/scripts/run-server.sh {{args}}