Skip to content

Commit 410c3ec

Browse files
committed
docs: Document command to generate local html coverage report
1 parent 07c462c commit 410c3ec

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

docs/how-to/coverage.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
21
# How to check code coverage
32

4-
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.
3+
## From the command line
4+
Code coverage is reported to the command line and to a `cov.xml` file by the
5+
command `uv run tox -e tests`. The file is uploaded to the Codecov service in
6+
CI.
7+
8+
To view the coverage locally in a view similar to codecov, pytest can generate
9+
html coverage info.
10+
11+
```sh
12+
$ uv run tox -e tests -- --cov-report html
13+
```
14+
15+
This will generate html in the `htmlcov` directory and opening
16+
`htmlcov/index.html` in a browser will show browsable coverage information.
517

6-
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:
18+
## From VSCode
19+
If you are using VSCode IDE, you can also check code coverage by right-clicking
20+
on the test icon and selecting `Run with coverage`. This will re-run the test
21+
and highlight line numbers in your file:
722
- Green = covered by tests
823
- Red = not covered (and ideally should be tested)
924

10-
## Adding a Codecov Token
25+
# Adding a Codecov Token
1126

12-
If the repo is not hosted in DiamondLightSource, then you need to visit `https://app.codecov.io/account/gh/<org_name>/org-upload-token` to generate a token for your org, and store it as a secret named `CODECOV_TOKEN` in `https://github.com/organizations/<org_name>/settings/secrets/actions`
27+
If the repo is not hosted in DiamondLightSource, then you need to visit
28+
`https://app.codecov.io/account/gh/<org_name>/org-upload-token` to generate a
29+
token for your org, and store it as a secret named `CODECOV_TOKEN` in
30+
`https://github.com/organizations/<org_name>/settings/secrets/actions`

0 commit comments

Comments
 (0)