chore: add code coverage
This commit is contained in:
1 parent
dd47ddac98
commit
f41d12b7fd
11 files changed
+59
-20
No files matched your search
@@ -3,6 +3,9 @@
|
||||
##
|
||||
## Get latest from `dotnet new gitignore`
|
||||
|
||||
# reportgenerator output
|
||||
CoverageReport/
|
||||
|
||||
# dotenv files
|
||||
.env
|
||||
|
||||
|
||||
@@ -2,5 +2,8 @@
|
||||
"sdk": {
|
||||
"version": "10.0.400",
|
||||
"rollForward": "latestFeature"
|
||||
},
|
||||
"test": {
|
||||
"runner": "Microsoft.Testing.Platform"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
Write-Host "Starting test execution..." -ForegroundColor Magenta
|
||||
Write-Host ""
|
||||
|
||||
dotnet test
|
||||
|
||||
|
||||
$TestExitCode = $LASTEXITCODE
|
||||
|
||||
if ($TestExitCode -eq 0) {
|
||||
Write-Host ""
|
||||
Write-Host "Tests passed. Generating code coverage HTML report..." -ForegroundColor Magenta
|
||||
Write-Host ""
|
||||
|
||||
reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"CoverageReport"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "SUCCESS: All tests passed and coverage report generated." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "FAILURE: Tests failed with exit code $TestExitCode. Skipping coverage report generation." -ForegroundColor Red
|
||||
}
|
||||
|
||||
exit $TestExitCode
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace StevanFreeborn.Atproto.IdentityResolver;
|
||||
|
||||
internal class Class1
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace StevanFreeborn.Atproto.IdentityResolver;
|
||||
|
||||
internal class Greeter
|
||||
{
|
||||
public static string SayHello()
|
||||
{
|
||||
return "Hi!";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
[*.cs]
|
||||
dotnet_diagnostic.CA1707.severity = none
|
||||
@@ -1,3 +1,9 @@
|
||||
<Project>
|
||||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
||||
<Import
|
||||
Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
|
||||
<TestingPlatformCommandLineArguments>--coverage --coverage-output-format cobertura</TestingPlatformCommandLineArguments>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -4,6 +4,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="AwesomeAssertions" Version="9.6.0" />
|
||||
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.10.0" />
|
||||
<PackageVersion Include="xunit.v3.mtp-v2" Version="4.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace StevanFreeborn.Atproto.IdentityResolver.Tests;
|
||||
|
||||
public class GreeterTests
|
||||
{
|
||||
[Fact]
|
||||
public void SayHello_WhenCalled_ItShouldReturnHi()
|
||||
{
|
||||
Greeter.SayHello().Should().Be("Hi!");
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,11 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -14,10 +11,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
<Using Include="AwesomeAssertions" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AwesomeAssertions" />
|
||||
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
|
||||
<PackageReference Include="xunit.v3.mtp-v2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace StevanFreeborn.Atproto.IdentityResolver.Tests;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
Assert.True(true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user