From 8b132b535bb435f3bd8d099949e37b49e83ffbeb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 31 Dec 2024 15:21:19 -0700 Subject: [PATCH] Enable MS Testing Platform This gets all tests running again. It also changes how test logs are collected to match changes from enabling the testing platform. However, discovery fails for some tests due to the need to execute code to load MSBuild from the SDK first, and the new xunit v3 discovery system apparently reflects before instantiating test classes, leading to these failures. --- CONTRIBUTING.md | 7 ++++++- .../Cake.GitVersioning.Tests.csproj | 1 + .../Nerdbank.GitVersioning.Tests.csproj | 1 + tools/dotnet-test-cloud.ps1 | 10 ++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 357e9c96..b99a89be 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,12 @@ NPM packages too. ## Testing -The Visual Studio 2019 Test Explorer will list and execute all tests. +`dotnet test` will run all tests. + +The Visual Studio 2022 Test Explorer will list and execute all tests. +Visual Studio needs a preview feature called "Use testing platform server mode" enabled. + +A few tests will fail without a certain VC++ toolset installed. ## Releases diff --git a/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj b/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj index f03810d6..83d93555 100644 --- a/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj +++ b/test/Cake.GitVersioning.Tests/Cake.GitVersioning.Tests.csproj @@ -3,6 +3,7 @@ net8.0 Exe + true false true false diff --git a/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj b/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj index 0d1d321d..abda9351 100644 --- a/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj +++ b/test/Nerdbank.GitVersioning.Tests/Nerdbank.GitVersioning.Tests.csproj @@ -3,6 +3,7 @@ net9.0 $(TargetFrameworks);net472 Exe + true true true full diff --git a/tools/dotnet-test-cloud.ps1 b/tools/dotnet-test-cloud.ps1 index 10cd4311..89ddc519 100644 --- a/tools/dotnet-test-cloud.ps1 +++ b/tools/dotnet-test-cloud.ps1 @@ -44,8 +44,8 @@ if ($x86) { } } -$testBinLog = Join-Path $ArtifactStagingFolder (Join-Path build_logs test.binlog) -$testDiagLog = Join-Path $ArtifactStagingFolder (Join-Path test_logs diag.log) +$testBinLog = Join-Path $ArtifactStagingFolder build_logs test.binlog +$testResultsDirectory = Join-Path $ArtifactStagingFolder test_logs & $dotnet test $RepoRoot ` --no-build ` @@ -56,8 +56,10 @@ $testDiagLog = Join-Path $ArtifactStagingFolder (Join-Path test_logs diag.log) --blame-hang-timeout 60s ` --blame-crash ` -bl:"$testBinLog" ` - --diag "$testDiagLog;TraceLevel=info" ` - --logger trx ` + -- ` + --results-directory $testResultsDirectory ` + --report-xunit-trx ` + --long-running 60 ` $unknownCounter = 0 Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% {