Skip to content

Commit 60f5a2b

Browse files
authored
Merge pull request #91 from firebase/hkj-code-cov
Coverlet code coverage utility integration
2 parents 6e24d5f + 093c56a commit 60f5a2b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Run the following commands from the command line to get your local environmentse
100100
```bash
101101
$ git clone https://github.com/firebase/firebase-admin-dotnet.git
102102
$ cd firebase-admin-dotnet/FirebaseAdmin # Change into the FirebaseAdmin solution directory
103-
$ dotnet restore # Install dependencies
103+
$ dotnet restore # Install dependencies
104104
```
105105

106106
### Running Tests
@@ -119,6 +119,24 @@ To run the unit test suite:
119119
$ dotnet test FirebaseAdmin.Tests
120120
```
121121

122+
To invoke code coverage tools, run the unit tests as follows:
123+
124+
```bash
125+
$ dotnet test FirebaseAdmin.Tests /p:CollectCoverage=true
126+
```
127+
128+
The above command calculates and displays a code coverage summary. To produce a more detailed
129+
code coverage report, you can use a tool like
130+
[Report Generator](https://github.com/danielpalme/ReportGenerator):
131+
132+
```bash
133+
$ dotnet test FirebaseAdmin.Tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
134+
$ dotnet path/to/ReportGenerator.dll -reports:./FirebaseAdmin.Tests/coverage.opencover.xml -targetdir:./reports
135+
```
136+
137+
This generates a collection of HTML code coverage reports in a local subdirectory named
138+
`reports/`.
139+
122140
The integration test suite requires a service account JSON key file, and an API key for a Firebase
123141
project. Create a new project in the [Firebase console](https://console.firebase.google.com) if
124142
you do not already have one. Use a separate, dedicated project for integration tests since the
@@ -143,4 +161,3 @@ Here are some highlights of the directory structure and notable source files
143161
* `FirebaseAdmin.Tests/` - Unit tests directory.
144162
* `FirebaseAdmin.IntegrationTests/` - Integration tests directory.
145163
* `FirebaseAdmin.Snippets/` - Example code snippets for the SDK.
146-

FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13+
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
1314
<PackageReference Include="Google.Apis.Auth" Version="1.40.0" />
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
1516
<PackageReference Include="xunit" Version="2.3.1" />

0 commit comments

Comments
 (0)