mirror of
https://github.com/bitwarden/server
synced 2025-12-13 14:53:34 +00:00
Implement Code Coverage
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -214,3 +214,4 @@ bitwarden_license/src/Portal/wwwroot/css
|
|||||||
bitwarden_license/src/Sso/wwwroot/lib
|
bitwarden_license/src/Sso/wwwroot/lib
|
||||||
bitwarden_license/src/Sso/wwwroot/css
|
bitwarden_license/src/Sso/wwwroot/css
|
||||||
.github/test/build.secrets
|
.github/test/build.secrets
|
||||||
|
**/CoverageOutput/
|
||||||
|
|||||||
@@ -7,6 +7,18 @@
|
|||||||
"commands": [
|
"commands": [
|
||||||
"swagger"
|
"swagger"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"coverlet.console": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"commands": [
|
||||||
|
"coverlet"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dotnet-reportgenerator-globaltool": {
|
||||||
|
"version": "4.8.8",
|
||||||
|
"commands": [
|
||||||
|
"reportgenerator"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
||||||
<PackageReference Include="NSubstitute" Version="4.2.2" />
|
<PackageReference Include="NSubstitute" Version="4.2.2" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
||||||
<PackageReference Include="NSubstitute" Version="4.2.2" />
|
<PackageReference Include="NSubstitute" Version="4.2.2" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
||||||
<PackageReference Include="NSubstitute" Version="4.2.2" />
|
<PackageReference Include="NSubstitute" Version="4.2.2" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
|||||||
38
test/coverage.ps1
Normal file
38
test/coverage.ps1
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
param(
|
||||||
|
[string][Alias('c')]$configuration = "Release",
|
||||||
|
[string][Alias('o')]$output = "CoverageOutput"
|
||||||
|
)
|
||||||
|
|
||||||
|
function Install-Tools {
|
||||||
|
dotnet tool install dotnet-reportgenerator-globaltool
|
||||||
|
dotnet tool install coverlet.console
|
||||||
|
}
|
||||||
|
|
||||||
|
function Print-Environment {
|
||||||
|
dotnet --version
|
||||||
|
dotnet tool run coverlet --version
|
||||||
|
}
|
||||||
|
|
||||||
|
function Prepare-Output {
|
||||||
|
if (Test-Path -Path $output) {
|
||||||
|
Remove-Item $output -Recurse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Run-Tests {
|
||||||
|
$testProjects = Get-ChildItem -Filter "*.Test.csproj" -Recurse
|
||||||
|
|
||||||
|
foreach ($testProject in $testProjects)
|
||||||
|
{
|
||||||
|
dotnet test $testProject.FullName /p:CoverletOutputFormatter="cobertura" --collect:"XPlat Code Coverage" --results-directory:"$output" -c $configuration
|
||||||
|
}
|
||||||
|
|
||||||
|
dotnet tool run reportgenerator -reports:$output/**/*.cobertura.xml -targetdir:$output -reporttypes:"Html;Cobertura"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Collecting Code Coverage"
|
||||||
|
|
||||||
|
Install-Tools
|
||||||
|
Print-Environment
|
||||||
|
Prepare-Output
|
||||||
|
Run-Tests
|
||||||
Reference in New Issue
Block a user