You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This chapter describes how to generate a traditional code coverage report over the Kotlin, Swift and Python code in the Glean SDK repository. To learn how to generate a coverage report about what metrics your project is testing, see the user documentation on [generating testing coverage reports](https://mozilla.github.io/glean/book/user/testing-metrics.html#generating-testing-coverage-reports).
8
+
This chapter describes how to generate a traditional code coverage report over the Kotlin, Swift and Python code in the Glean SDK repository.
Copy file name to clipboardExpand all lines: docs/user/user/metrics/testing-metrics.md
-52Lines changed: 0 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,6 @@ in any client application it may be used in.
7
7
These functions expose a way to inspect and validate recorded metric values within the client application. but are restricted to test code only.
8
8
(Outside of a testing context, Glean APIs are otherwise write-only so that it can enforce semantics and constraints about data).
9
9
10
-
To encourage using the testing APIs, it is also possible to [generate testing coverage reports](#generating-testing-coverage-reports) to show which metrics in your project are tested.
11
-
12
10
## Example of using the test API
13
11
14
12
In order to enable metrics testing APIs in each SDK, Glean must be reset and put in testing mode.
Glean can generate coverage reports to track which metrics are tested in your unit test suite.
91
-
92
-
There are three steps to integrate it into your continuous integration workflow: recording coverage, post-processing the results, and uploading the results.
93
-
94
-
### Recording coverage
95
-
96
-
Glean testing coverage is enabled by setting the `GLEAN_TEST_COVERAGE` environment variable to the name of a file to store results.
97
-
It is good practice to set it to the absolute path to a file, since some testing harnesses (such as `cargo test`) may change the current working directory.
98
-
99
-
```bash
100
-
GLEAN_TEST_COVERAGE=$(realpath glean_coverage.txt) make test
101
-
```
102
-
103
-
### Post-processing the results
104
-
105
-
A post-processing step is required to convert the raw output in the file specified by `GLEAN_TEST_COVERAGE` into usable output for coverage reporting tools. Currently, the only coverage reporting tool supported is [codecov.io](https://codecov.io).
106
-
107
-
This post-processor is available in the `coverage` subcommand in the [`glean_parser`](https://github.com/mozilla/glean_parser) tool.
108
-
109
-
For some build systems, `glean_parser` is already installed for you by the build system integration at the following locations:
110
-
111
-
- On Android/Gradle, `$GRADLE_HOME/glean/bootstrap-4.5.11/Miniconda3/bin/glean_parser`
112
-
- On iOS, `$PROJECT_ROOT/.venv/bin/glean_parser`
113
-
- For other systems, install `glean_parser` using `pip install glean_parser`
114
-
115
-
The `glean_parser coverage` command requires the following parameters:
116
-
117
-
-`-f`: The output format to produce, for example `codecovio` to produce [codecov.io](https://codecov.io)'s custom format.
118
-
-`-o`: The path to the output file, for example `codecov.json`.
119
-
-`-c`: The input raw coverage file. `glean_coverage.txt` in the example above.
120
-
- A list of the `metrics.yaml` files in your repository.
121
-
122
-
For example, to produce output for [codecov.io](https://codecov.io):
In this example, the `glean_coverage.json` file is now ready for uploading to codecov.io.
129
-
130
-
### Uploading coverage
131
-
132
-
If using `codecov.io`, the uploader doesn't send coverage results for YAML files by default. Pass the `-X yaml` option to the uploader to make sure they are included:
0 commit comments