Skip to content

Commit b800daf

Browse files
authored
docs: document dotnet coverage workflow (#2409)
1 parent fc5bb19 commit b800daf

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,57 @@ Additional root-level documents provide deeper insights into the project:
3535
- [EVENTSTREAM_EVENTS.md](EVENTSTREAM_EVENTS.md) – lists key EventStream events and their publishers/subscribers.
3636
- [SECURITY.md](SECURITY.md) – security policy and supported versions.
3737
- [Terminology.md](Terminology.md) – definitions of common Proto.Actor terms.
38-
39-
## Design principles
38+
39+
## Test coverage
40+
41+
You can capture code coverage directly when running the test projects. The .NET SDK ships an `XPlat Code Coverage` data collector that works across platforms, so you do not need any third-party tooling for the basic workflow.
42+
43+
### Quick coverage run
44+
45+
Run any test project with coverage enabled by passing the `CollectCoverage` property:
46+
47+
```bash
48+
dotnet test /p:CollectCoverage=true
49+
```
50+
51+
This uses the built-in collector and writes coverage data under the `TestResults` directory for the invocation.
52+
53+
### Using coverlet.collector
54+
55+
For richer reporting support you can opt into the `coverlet.collector` package. Add it to the test project you want to analyze:
56+
57+
```bash
58+
dotnet add package coverlet.collector
59+
```
60+
61+
Then request coverage when running the tests:
62+
63+
```bash
64+
dotnet test --collect:"XPlat Code Coverage"
65+
```
66+
67+
This produces a `.coverage` file under `TestResults/...` that can be converted into other formats.
68+
69+
### Alternative output formats
70+
71+
You can ask the collector to emit other formats such as Cobertura, lcov, or OpenCover. For example, to produce an `lcov` report:
72+
73+
```bash
74+
dotnet test --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=lcov
75+
```
76+
77+
### HTML reports
78+
79+
Feed the generated `lcov` or `cobertura` files into tools like [ReportGenerator](https://github.com/danielpalme/ReportGenerator) to build browsable HTML output. Install the global tool and point it at your coverage reports:
80+
81+
```bash
82+
dotnet tool install -g dotnet-reportgenerator-globaltool
83+
reportgenerator -reports:**/coverage.cobertura.xml -targetdir:coveragereport
84+
```
85+
86+
Open the files in the `coveragereport` directory to inspect the results.
87+
88+
## Design principles
4089

4190
**Minimalistic API** - The API should be small and easy to use. Avoid enterprisey containers and configurations.
4291

context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Repository Root Context
22

33
## Overview
4-
Root of the Proto.Actor for .NET repository. Hosts the runtime, clustering, remote communication, persistence providers, tooling, tests, and numerous samples.
4+
Root of the Proto.Actor for .NET repository. Hosts the runtime, clustering, remote communication, persistence providers, tooling, tests, and numerous samples. The `README.md` document also summarizes how to collect code coverage with the .NET SDK for contributors verifying their changes.
55

66
Start here, but also read [`README.md`](README.md) for project onboarding, then dive into [`src/context.md`](src/context.md), [`tests/context.md`](tests/context.md), and [`examples/context.md`](examples/context.md) for subsystem-specific guides.
77

0 commit comments

Comments
 (0)