Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions docs/how-to/coverage.md
Original file line number Diff line number Diff line change
@@ -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_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`
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`