mirror of
https://github.com/MAKS-IT-COM/maksit-hamode.git
synced 2026-09-30 00:18:08 +02:00
(test): migrate to xunit.v3 4.0 and microsoft testing platform
This commit is contained in:
parent
260515131b
commit
362e353e43
@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.0.8] - 2026-08-18
|
||||
|
||||
### Changed
|
||||
- Migrated tests to xunit.v3 `4.0` and Microsoft Testing Platform only (`src/global.json` `test.runner` next to the `.slnx`; no VSTest, `coverlet.collector`, `Microsoft.NET.Test.Sdk`, or `xunit.runner.visualstudio`). Coverage now uses `coverlet.MTP`; TestRunner always passes `--coverlet` scoped to `[MaksIT.*]*`.
|
||||
|
||||
## [1.0.7] - 2026-08-14
|
||||
|
||||
### Changed
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
Reusable high-availability runtime coordination library for MaksIT services.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Packages
|
||||
|
||||
|
||||
@ -6,21 +6,15 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<OutputType>Exe</OutputType>
|
||||
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="10.0.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.MTP" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.11" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.v3" Version="3.2.2" />
|
||||
<PackageReference Include="xunit.v3" Version="4.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
|
||||
<PackageId>MaksIT.HAMode</PackageId>
|
||||
<Version>1.0.7</Version>
|
||||
<Version>1.0.8</Version>
|
||||
<Authors>Maksym Sadovnychyy</Authors>
|
||||
<Company>MAKS-IT</Company>
|
||||
<Product>MaksIT.HAMode</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
|
||||
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
|
||||
Author: MaksIT
|
||||
@ -65,6 +65,20 @@ function Write-TestRunnerLogInternal {
|
||||
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 {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
@ -155,7 +169,7 @@ function Invoke-TestsWithCoverage {
|
||||
New-Item -ItemType Directory -Path $ResultsDir -Force | Out-Null
|
||||
|
||||
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) {
|
||||
Write-TestRunnerLogInternal -Level "INFO" -Message "Test Project: $d"
|
||||
}
|
||||
@ -164,11 +178,15 @@ function Invoke-TestsWithCoverage {
|
||||
foreach ($TestProjectDir in $resolvedProjectDirs) {
|
||||
Push-Location $TestProjectDir
|
||||
try {
|
||||
$projectName = [System.IO.Path]::GetFileName($TestProjectDir)
|
||||
$dotnetArgs = @(
|
||||
"test"
|
||||
"--collect:XPlat Code Coverage"
|
||||
"--results-directory", $ResultsDir
|
||||
"--verbosity", $(if ($Silent) { "quiet" } else { "normal" })
|
||||
"--coverlet"
|
||||
"--coverlet-output-format", "cobertura"
|
||||
"--coverlet-file-prefix", $projectName
|
||||
"--coverlet-include", "[MaksIT.*]*"
|
||||
)
|
||||
|
||||
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) {
|
||||
return [PSCustomObject]@{
|
||||
@ -455,7 +473,7 @@ function Get-DotNetCoverageFromResultsDirectory {
|
||||
[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) {
|
||||
return [PSCustomObject]@{
|
||||
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'
|
||||
$hasNpm = Test-Path -LiteralPath $jestSummary -PathType Leaf
|
||||
|
||||
|
||||
@ -7,12 +7,15 @@
|
||||
|
||||
.DESCRIPTION
|
||||
Resolves one or more .NET test projects (`project` or `projects`), runs tests once
|
||||
via TestRunner, then publishes metrics on the shared engine context for any later
|
||||
via TestRunner (Microsoft Testing Platform + coverlet.MTP only — no VSTest /
|
||||
coverlet.collector), then publishes metrics on the shared engine context for any later
|
||||
plugin: `qualityLineCoverage`, `testResult`, `coverageLineRate` / `coverageBranchRate` / `coverageMethodRate`,
|
||||
method counts, `testResultsDirectory`, `coverageCoberturaPaths`. Quality gates read
|
||||
those keys generically (not tied to this plugin by name). When `resultsDir` (or the
|
||||
multi-project default TestResults folder) is used, Cobertura output is kept on disk
|
||||
via TestRunner `-KeepResults` so repo-root `test-results/` persists after the run.
|
||||
Product solutions must place `src/global.json` with `test.runner` =
|
||||
Microsoft.Testing.Platform next to the `.sln`/`.slnx`.
|
||||
#>
|
||||
|
||||
if (-not (Get-Command Import-PluginDependency -ErrorAction SilentlyContinue)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user