mirror of
https://github.com/bitwarden/server.git
synced 2024-12-22 16:57:36 +01:00
Implement Code Coverage
This commit is contained in:
parent
a48f024113
commit
4ada179ada
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/css
|
||||
.github/test/build.secrets
|
||||
**/CoverageOutput/
|
||||
|
@ -7,6 +7,18 @@
|
||||
"commands": [
|
||||
"swagger"
|
||||
]
|
||||
},
|
||||
"coverlet.console": {
|
||||
"version": "3.0.3",
|
||||
"commands": [
|
||||
"coverlet"
|
||||
]
|
||||
},
|
||||
"dotnet-reportgenerator-globaltool": {
|
||||
"version": "4.8.8",
|
||||
"commands": [
|
||||
"reportgenerator"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<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="NSubstitute" Version="4.2.2" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
|
@ -6,6 +6,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<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="NSubstitute" Version="4.2.2" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
|
@ -5,6 +5,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<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="NSubstitute" Version="4.2.2" />
|
||||
<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
|
Loading…
Reference in New Issue
Block a user