From 410c3ec6a76b05143564e4fe7d000e221d97b6b2 Mon Sep 17 00:00:00 2001 From: Peter Holloway Date: Tue, 20 Jan 2026 15:36:18 +0000 Subject: [PATCH] docs: Document command to generate local html coverage report --- docs/how-to/coverage.md | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/how-to/coverage.md b/docs/how-to/coverage.md index 5838704fde..fb17a1de4b 100644 --- a/docs/how-to/coverage.md +++ b/docs/how-to/coverage.md @@ -1,12 +1,30 @@ - # How to check code coverage -Code coverage is reported to the command line and to a `cov.xml` file by the command `uv run tox -e tests`. The file is uploaded to the Codecov service in CI. +## From the command line +Code coverage is reported to the command line and to a `cov.xml` file by the +command `uv run tox -e tests`. The file is uploaded to the Codecov service in +CI. + +To view the coverage locally in a view similar to codecov, pytest can generate +html coverage info. + + ```sh + $ uv run tox -e tests -- --cov-report html + ``` + +This will generate html in the `htmlcov` directory and opening +`htmlcov/index.html` in a browser will show browsable coverage information. -If you are using VSCode IDE, you can also check code coverage by right-clicking on the test icon and selecting `Run with coverage`. This will re-run the test and highlight line numbers in your file: +## From VSCode +If you are using VSCode IDE, you can also check code coverage by right-clicking +on the test icon and selecting `Run with coverage`. This will re-run the test +and highlight line numbers in your file: - Green = covered by tests - Red = not covered (and ideally should be tested) -## Adding a Codecov Token +# Adding a Codecov Token -If the repo is not hosted in DiamondLightSource, then you need to visit `https://app.codecov.io/account/gh//org-upload-token` to generate a token for your org, and store it as a secret named `CODECOV_TOKEN` in `https://github.com/organizations//settings/secrets/actions` +If the repo is not hosted in DiamondLightSource, then you need to visit +`https://app.codecov.io/account/gh//org-upload-token` to generate a +token for your org, and store it as a secret named `CODECOV_TOKEN` in +`https://github.com/organizations//settings/secrets/actions`