|
1 | | - |
2 | 1 | # How to check code coverage |
3 | 2 |
|
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. |
5 | 17 |
|
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: |
7 | 22 | - Green = covered by tests |
8 | 23 | - Red = not covered (and ideally should be tested) |
9 | 24 |
|
10 | | -## Adding a Codecov Token |
| 25 | +# Adding a Codecov Token |
11 | 26 |
|
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