(chore): migrate tests to MTP
This commit is contained in:
parent
8db977da95
commit
2a64aa43b3
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [2.2.2] - 2026-08-16
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **Tests:** migrate to **xunit.v3** **4.0.0** + **Microsoft Testing Platform** only (`src/global.json` `test.runner`; no VSTest / **coverlet.collector** / **Microsoft.NET.Test.Sdk** / **xunit.runner.visualstudio**). Use **coverlet.MTP**; **TestRunner** always uses `--coverlet`.
|
||||||
|
- Package version **2.2.2**.
|
||||||
|
|
||||||
## [2.2.1] - 2026-08-14
|
## [2.2.1] - 2026-08-14
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@ -35,6 +35,8 @@ pwsh -File .\utils\engines\test\Invoke-TestEngine.ps1
|
|||||||
|
|
||||||
Or double-click `utils\Invoke-TestEngine.bat`.
|
Or double-click `utils\Invoke-TestEngine.bat`.
|
||||||
|
|
||||||
|
Tests run under **Microsoft Testing Platform** (`src/global.json` `test.runner`) with **xunit.v3** and **coverlet.MTP**.
|
||||||
|
|
||||||
Quick local run:
|
Quick local run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
# MaksIT.Dapr
|
# MaksIT.Dapr
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
NuGet facade over [Dapr](https://dapr.io/) for ASP.NET Core: pub/sub, state, invocation, bindings, secrets, configuration, cryptography, sidecar, lock, HA work leases, actors, and workflows — all with `MaksIT.Results` outcomes.
|
NuGet facade over [Dapr](https://dapr.io/) for ASP.NET Core: pub/sub, state, invocation, bindings, secrets, configuration, cryptography, sidecar, lock, HA work leases, actors, and workflows — all with `MaksIT.Results` outcomes.
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ dotnet add package MaksIT.Dapr
|
|||||||
Or in your `.csproj`:
|
Or in your `.csproj`:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<PackageReference Include="MaksIT.Dapr" Version="2.2.1" />
|
<PackageReference Include="MaksIT.Dapr" Version="2.2.2" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## Registering services
|
## Registering services
|
||||||
|
|||||||
@ -5,18 +5,16 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
|
||||||
<NoWarn>$(NoWarn);xUnit1051</NoWarn>
|
<NoWarn>$(NoWarn);xUnit1051</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="10.0.1">
|
<PackageReference Include="coverlet.MTP" Version="10.0.1" />
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
|
|
||||||
<PackageReference Include="Moq" Version="4.*" />
|
<PackageReference Include="Moq" Version="4.*" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.*" />
|
<PackageReference Include="xunit.v3" Version="4.0.0" />
|
||||||
<PackageReference Include="xunit.v3" Version="3.*" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<!-- NuGet package metadata -->
|
<!-- NuGet package metadata -->
|
||||||
<PackageId>MaksIT.Dapr</PackageId>
|
<PackageId>MaksIT.Dapr</PackageId>
|
||||||
<Version>2.2.1</Version>
|
<Version>2.2.2</Version>
|
||||||
<Authors>Maksym Sadovnychyy</Authors>
|
<Authors>Maksym Sadovnychyy</Authors>
|
||||||
<Company>MAKS-IT</Company>
|
<Company>MAKS-IT</Company>
|
||||||
<Product>MaksIT.Dapr</Product>
|
<Product>MaksIT.Dapr</Product>
|
||||||
|
|||||||
5
src/global.json
Normal file
5
src/global.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"test": {
|
||||||
|
"runner": "Microsoft.Testing.Platform"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Provides the Invoke-TestsWithCoverage function for running .NET tests
|
Provides the Invoke-TestsWithCoverage function for running .NET tests
|
||||||
with Coverlet code coverage collection and parsing results.
|
with Microsoft.Testing.Platform and coverlet.MTP code coverage.
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: MaksIT
|
Author: MaksIT
|
||||||
@ -65,6 +65,20 @@ function Write-TestRunnerLogInternal {
|
|||||||
Write-Host $Message -ForegroundColor Gray
|
Write-Host $Message -ForegroundColor Gray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-CoberturaCoverageFiles {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$ResultsDirectory
|
||||||
|
)
|
||||||
|
|
||||||
|
# coverlet.MTP: [prefix.]coverage.cobertura[.timestamp].xml
|
||||||
|
$files = @(
|
||||||
|
Get-ChildItem -Path $ResultsDirectory -Recurse -File -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object { $_.Name -like '*coverage.cobertura*.xml' }
|
||||||
|
)
|
||||||
|
return @($files | Sort-Object FullName -Unique)
|
||||||
|
}
|
||||||
|
|
||||||
function Invoke-TestsWithCoverage {
|
function Invoke-TestsWithCoverage {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
@ -155,7 +169,7 @@ function Invoke-TestsWithCoverage {
|
|||||||
New-Item -ItemType Directory -Path $ResultsDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $ResultsDir -Force | Out-Null
|
||||||
|
|
||||||
if (-not $Silent) {
|
if (-not $Silent) {
|
||||||
Write-TestRunnerLogInternal -Level "STEP" -Message "Running tests with code coverage..."
|
Write-TestRunnerLogInternal -Level "STEP" -Message "Running tests with code coverage (Microsoft.Testing.Platform / coverlet.MTP)..."
|
||||||
foreach ($d in $resolvedProjectDirs) {
|
foreach ($d in $resolvedProjectDirs) {
|
||||||
Write-TestRunnerLogInternal -Level "INFO" -Message "Test Project: $d"
|
Write-TestRunnerLogInternal -Level "INFO" -Message "Test Project: $d"
|
||||||
}
|
}
|
||||||
@ -164,11 +178,15 @@ function Invoke-TestsWithCoverage {
|
|||||||
foreach ($TestProjectDir in $resolvedProjectDirs) {
|
foreach ($TestProjectDir in $resolvedProjectDirs) {
|
||||||
Push-Location $TestProjectDir
|
Push-Location $TestProjectDir
|
||||||
try {
|
try {
|
||||||
|
$projectName = [System.IO.Path]::GetFileName($TestProjectDir)
|
||||||
$dotnetArgs = @(
|
$dotnetArgs = @(
|
||||||
"test"
|
"test"
|
||||||
"--collect:XPlat Code Coverage"
|
|
||||||
"--results-directory", $ResultsDir
|
"--results-directory", $ResultsDir
|
||||||
"--verbosity", $(if ($Silent) { "quiet" } else { "normal" })
|
"--verbosity", $(if ($Silent) { "quiet" } else { "normal" })
|
||||||
|
"--coverlet"
|
||||||
|
"--coverlet-output-format", "cobertura"
|
||||||
|
"--coverlet-file-prefix", $projectName
|
||||||
|
"--coverlet-include", "[MaksIT.*]*"
|
||||||
)
|
)
|
||||||
|
|
||||||
Import-ExternalCommandSupportInternal
|
Import-ExternalCommandSupportInternal
|
||||||
@ -192,7 +210,7 @@ function Invoke-TestsWithCoverage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$coverageFiles = @(Get-ChildItem -Path $ResultsDir -Filter "coverage.cobertura.xml" -Recurse | Sort-Object FullName)
|
$coverageFiles = @(Get-CoberturaCoverageFiles -ResultsDirectory $ResultsDir)
|
||||||
|
|
||||||
if ($coverageFiles.Count -eq 0) {
|
if ($coverageFiles.Count -eq 0) {
|
||||||
return [PSCustomObject]@{
|
return [PSCustomObject]@{
|
||||||
@ -455,7 +473,7 @@ function Get-DotNetCoverageFromResultsDirectory {
|
|||||||
[switch]$Silent
|
[switch]$Silent
|
||||||
)
|
)
|
||||||
|
|
||||||
$coverageFiles = @(Get-ChildItem -Path $ResultsDirectory -Filter 'coverage.cobertura.xml' -Recurse -ErrorAction SilentlyContinue | Sort-Object FullName)
|
$coverageFiles = @(Get-CoberturaCoverageFiles -ResultsDirectory $ResultsDirectory)
|
||||||
if ($coverageFiles.Count -eq 0) {
|
if ($coverageFiles.Count -eq 0) {
|
||||||
return [PSCustomObject]@{
|
return [PSCustomObject]@{
|
||||||
Success = $false
|
Success = $false
|
||||||
@ -566,7 +584,7 @@ function Get-CoverageFromResultsDirectory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$hasDotNet = @(Get-ChildItem -Path $resolvedDirectory -Filter 'coverage.cobertura.xml' -Recurse -ErrorAction SilentlyContinue).Count -gt 0
|
$hasDotNet = @(Get-CoberturaCoverageFiles -ResultsDirectory $resolvedDirectory).Count -gt 0
|
||||||
$jestSummary = Join-Path $resolvedDirectory 'coverage-summary.json'
|
$jestSummary = Join-Path $resolvedDirectory 'coverage-summary.json'
|
||||||
$hasNpm = Test-Path -LiteralPath $jestSummary -PathType Leaf
|
$hasNpm = Test-Path -LiteralPath $jestSummary -PathType Leaf
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user