Repository navigation
Migrate VMR test projects to xunit.v3 and Microsoft.Testing.Platform - #8060
Merged
Merged
Conversation
The test projects under test/ were xunit v2 running on VSTest. Move them to xunit.v3 on Microsoft.Testing.Platform (MTP). Build configuration: - Disable Arcade's test infrastructure (DisableArcadeTestFramework). MTP brings its own Test/InvokeTestingPlatform target, so Arcade's parallel Test/RunTests targets and the xunit package references it injects are no longer needed. - Replace the VSTest properties (VSTestLogger, VSTestCLIRunSettings, VSTestResultsDirectory, VSTestUseMSBuildOutput) with a single TestingPlatformCommandLineArguments property, and delete eng/Tests.targets, which forced the Test target to depend on VSTest. - Reference the xunit.v3 meta package; it pulls in xunit.v3.mtp-v2 (core, assert and analyzers) which in turn brings MTP and its MSBuild integration. Microsoft.Testing.Platform.MSBuild is pinned forward because xunit.v3 asks for an older version that doesn't support --ignore-exit-code. - Declare the MTP runner in global.json so dotnet test uses the same path. Test reports are emitted explicitly (MTP produces none by default) into artifacts/TestResults, matching what the pipelines publish. Runs where every test is skipped no longer fail: many of these tests are conditional on the build configuration, and MTP reports "zero tests ran" as exit code 8. Code changes: - Convert the custom [ConditionalFact]/[ConditionalTheory] attributes to xunit v3's built-in [Fact(SkipUnless=...)]/[Theory(SkipUnless=...)] and delete the v2-only discoverer infrastructure they depended on. - Drop the Xunit.Abstractions using directives; ITestOutputHelper moved into the Xunit namespace and gained Write/Output members. Test applications are launched directly as app hosts rather than through the dotnet muxer, and an app host resolves its runtime via DOTNET_ROOT rather than PATH. Set it to the repo-local SDK so tests don't silently run against whatever .NET happens to be installed on the machine. See microsoft/testfx#10342. Co-authored-by: Copilot <[email protected]> Copilot-Session: 761287f0-d9eb-4740-974e-b168dab091a8
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
…OOT workaround microsoft/testfx#10413 makes InvokeTestingPlatformTask configure DOTNET_ROOT for app host launches automatically, so the inline task that set the variable on the MSBuild process is no longer needed. That fix isn't on the regular feeds yet, so pick it up from the testfx test-tools preview channel (https://aka.ms/mstest/preview) by overriding the Arcade default for MicrosoftTestingPlatformVersion. Both can be reverted once a release containing the fix flows to the regular feeds. Verified that the test applications still run against the repo-local .NET installation with no DOTNET_ROOT set in the environment. Co-authored-by: Copilot <[email protected]> Copilot-Session: 761287f0-d9eb-4740-974e-b168dab091a8
ViktorHofer
force-pushed
the
ViktorHofer/test-xunit-v3-mtp
branch
from
August 4, 2026 08:29
e8a3ded to
261c93a
Compare
ViktorHofer
marked this pull request as ready for review
August 4, 2026 08:30
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the VMR-level test projects under test/ from xUnit.net v2 + VSTest to xUnit.net v3 running on Microsoft.Testing.Platform (MTP), simplifying test execution to a single MTP-based path and updating pipeline invocations accordingly.
Changes:
- Replaces custom conditional test discovery (
ConditionalFact/ConditionalTheorydiscoverers + skipped test case plumbing) with xUnit v3’s built-inSkipUnlesssupport and removes the v2-only infrastructure. - Switches test execution configuration to MTP via
TestingPlatformCommandLineArguments, including explicit TRX/XML/HTML report emission intoartifacts/TestResults. - Updates repo configuration and pipelines for the MTP runner and pins a preview
Microsoft.Testing.Platformbuild via a new feed entry.
Show a summary per file
| File | Description |
|---|---|
| test/TestUtilities/TestUtilities.csproj | Updates xUnit dependencies for v3 extensibility usage in test utilities. |
| test/TestUtilities/SkippedTestCase.cs | Removes xUnit v2-specific skipped test case implementation. |
| test/TestUtilities/ExecuteHelper.cs | Updates ITestOutputHelper namespace usage for xUnit v3. |
| test/TestUtilities/ConditionalTheoryDiscoverer.cs | Removes xUnit v2 conditional theory discoverer implementation. |
| test/TestUtilities/ConditionalTheoryAttribute.cs | Removes xUnit v2 conditional theory attribute. |
| test/TestUtilities/ConditionalTestDiscoverer.cs | Removes shared xUnit v2 conditional discovery logic. |
| test/TestUtilities/ConditionalFactDiscoverer.cs | Removes xUnit v2 conditional fact discoverer implementation. |
| test/TestUtilities/ConditionalFactAttribute.cs | Removes xUnit v2 conditional fact attribute. |
| test/TestUtilities/ConditionalDiscovererException.cs | Removes exception type used by the removed v2 discoverers. |
| test/TestUtilities/BaselineHelper.cs | Updates ITestOutputHelper namespace usage for xUnit v3. |
| test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.Tests/PackageSourceMappingsTests.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.Tests/Microsoft.DotNet.Tests.csproj | Removes VSTest-specific project properties. |
| test/Microsoft.DotNet.Tests/CentralPackageManagementTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.Tests/BinaryScanTest.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.SourceBuild.Tests/WebScenarioTests.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/Utilities.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/TestBase.cs | Updates ITestOutputHelper namespace usage for xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/SymbolsTests.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/SourcelinkTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.SourceBuild.Tests/SourceBuiltArtifactsTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.SourceBuild.Tests/SdkTests.cs | Updates ITestOutputHelper namespace usage for xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/SdkContentTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.SourceBuild.Tests/PoisonTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.SourceBuild.Tests/OmniSharpTests.cs | Converts conditional theories to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.SourceBuild.Tests/Microsoft.DotNet.SourceBuild.Tests.csproj | Removes VSTest-specific project properties. |
| test/Microsoft.DotNet.SourceBuild.Tests/LicenseScanTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.SourceBuild.Tests/HttpClientExtensions.cs | Updates ITestOutputHelper namespace usage for xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/DotNetWatchTests.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/DotNetHelper.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/DotNetFormatTests.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/DebugTests.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/DebugTestOutputHelper.cs | Updates to xUnit v3 ITestOutputHelper shape (adds Output/Write). |
| test/Microsoft.DotNet.SourceBuild.Tests/BaselineHelper.cs | Removes xUnit v2 abstractions usage in favor of xUnit v3. |
| test/Microsoft.DotNet.SourceBuild.Tests/ArtifactsSizeTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.Reproducibility.Tests/ReproducibilityTests.cs | Converts conditional tests to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.Reproducibility.Tests/Microsoft.DotNet.Reproducibility.Tests.csproj | Removes VSTest-specific project properties. |
| test/Microsoft.DotNet.Installer.Tests/Microsoft.DotNet.Installer.Tests.csproj | Removes VSTest-specific project properties. |
| test/Microsoft.DotNet.Installer.Tests/LinuxInstallerTests.cs | Converts conditional facts/theories to xUnit v3 SkipUnless usage. |
| test/Microsoft.DotNet.Installer.Tests/DockerHelper.cs | Updates ITestOutputHelper namespace usage for xUnit v3. |
| test/Directory.Build.props | Defines MTP test app settings and standardizes report generation + results dir. |
| src/global.json | Adds a global.json under src/ (currently empty). |
| NuGet.config | Adds test-tools feed for early-access Microsoft.Testing.Platform packages. |
| global.json | Sets MTP as the dotnet test runner and pins SDK selection behavior. |
| eng/Versions.props | Removes VSTest runner setting and pins MicrosoftTestingPlatformVersion. |
| eng/Tests.targets | Removes VSTest-overriding Test target. |
| eng/pipelines/templates/stages/vmr-license-scan.yml | Updates dotnet test invocation to MTP/xUnit v3 filtering/output args. |
| eng/pipelines/templates/jobs/sdk-diff-tests.yml | Updates dotnet test invocation to MTP/xUnit v3 filtering/output args. |
| eng/build.ps1 | Removes VSTest hang workaround env var for test runs. |
| Directory.Packages.props | Switches CPM entries to xUnit v3 and pins MTP MSBuild integration forward. |
| Directory.Build.props | Disables Arcade test framework integration and keeps repo-wide compiler settings. |
| build.sh | Removes VSTest-related env var workarounds for test runs. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 52/52 changed files
- Comments generated: 1
Evangelink
reviewed
Aug 4, 2026
Evangelink
reviewed
Aug 4, 2026
akoeplinger
reviewed
Aug 6, 2026
Co-authored-by: ViktorHofer <[email protected]>
Co-authored-by: ViktorHofer <[email protected]>
xUnit.net v3 requires Skip to be set whenever SkipWhen or SkipUnless is used; without it every conditional test fails at runtime with 'You must set Skip when you set SkipUnless or SkipWhen ... to set the message for conditional skips' instead of being skipped. This only surfaces once a condition actually triggers a skip, which is why it showed up in CI rather than locally. Also turn on the two Microsoft.Testing.Platform reporting switches. Both default to the quiet setting, so a failing run logged a single error pointing at a log file that isn't published, leaving no way to tell which tests failed or why from the build log alone. Co-authored-by: Copilot <[email protected]> Copilot-Session: 761287f0-d9eb-4740-974e-b168dab091a8
Member
Author
@akoeplinger turns out the Skip message is actually required otherwise xunit throws at run time. |
When --with-sdk points the build at an SDK whose version differs from the one pinned in the root global.json, the build fails during toolset initialization with 'A compatible .NET SDK was not found' before anything gets built: the SDK resolver reads sdk/version and Arcade's tools.sh reads tools/dotnet, and neither matches the SDK actually in use. Rewrite both entries to the custom SDK's version, mirroring what the UpdateGlobalJsonVersions target already does for each repository underneath. Both build.sh and prep-source-build.sh route --with-sdk through source_only_toolset_init, so this covers both. Each substitution is scoped to the object owning the key so unrelated entries are left alone. Co-authored-by: Copilot <[email protected]> Copilot-Session: 761287f0-d9eb-4740-974e-b168dab091a8
TestingPlatformShowTestsFailure alone gives the failure detail: the task only logs errors in response to a failed test, so a passing run prints the same single-line summary it did before. TestingPlatformCaptureOutput=false instead routes every line the test process writes through MSBuild logging regardless of the outcome, which isn't needed to diagnose failures. Co-authored-by: Copilot <[email protected]> Copilot-Session: 761287f0-d9eb-4740-974e-b168dab091a8
--output Detailed was carried over as a translation of the old VSTest 'console;verbosity=detailed' logger, but Microsoft.Testing.Platform already reports the assertion message and stack trace of a failing test at its default level. The option only adds a line per passing test, which for these runs is noise. Co-authored-by: Copilot <[email protected]> Copilot-Session: 761287f0-d9eb-4740-974e-b168dab091a8
Member
Author
|
OK this PR is now officially ready and will turn green :) I expect minor time savings but more importantly a modern UX due to xunit v3 + MTP. |
akoeplinger
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the test projects under
test/from xUnit.net v2 on VSTest to xUnit.net v3 on Microsoft.Testing.Platform (MTP).Build configuration
Arcade's test infrastructure is disabled (
DisableArcadeTestFramework). MTP contributes its ownTest→InvokeTestingPlatformtarget that builds the project and executes the test application, so Arcade's parallelTest/RunTeststargets and the xunit package references it injects aren't needed.eng/Tests.targetsis deleted; it overrode theTesttarget to depend onVSTest, which would otherwise shadow MTP's.That leaves one execution path shared by
build.cmd -test,dotnet testanddotnet msbuild -t:Test.global.jsondeclares the MTP runner sodotnet testuses it too.The per-project VSTest properties (
VSTestLogger,VSTestCLIRunSettings,VSTestResultsDirectory,VSTestUseMSBuildOutput) collapse into a singleTestingPlatformCommandLineArgumentsproperty intest/Directory.Build.props.Packages reduce to a single
xunit.v3reference: it pulls inxunit.v3.mtp-v2(core, assert, analyzers), which brings MTP and its MSBuild integration transitively.Microsoft.Testing.Platform.MSBuildis pinned forward becausexunit.v3asks for an older version that predates--ignore-exit-code.Two behaviours are worth calling out:
artifacts/TestResultsas<Project>.trx/.xml/.html(the xunit writers, so no extraMicrosoft.Testing.Extensions.*package).Code changes
The custom
[ConditionalFact]/[ConditionalTheory]attributes are replaced by xunit v3's built-in support:The v2-only discoverer infrastructure they relied on (
ConditionalFactDiscoverer,ConditionalTheoryDiscoverer,ConditionalTestDiscoverer,SkippedTestCase, …) is deleted — 7 files, ~370 lines.using Xunit.Abstractions;is gone throughout;ITestOutputHelpermoved into theXunitnamespace and gainedWrite/Outputmembers, whichDebugTestOutputHelpernow implements.Runtime selection
xunit.v3 requires an app host, and MTP launches that executable directly rather than through the
dotnetmuxer. An app host ignoresPATH— it resolves a runtime throughDOTNET_ROOTand otherwise falls back to the machine-wide install. Arcade's runner target used to set this; with Arcade's test infrastructure disabled, nothing did, so tests silently ran on the machine-wide runtime instead of the repo-local SDK, and would fail outright on a machine with no .NET installed:microsoft/testfx#10413 fixes this upstream:
InvokeTestingPlatformTasknow configuresDOTNET_ROOTfor app host launches itself, and theInvokeTestingPlatformtarget gained aTestingPlatformEnvironmentVariableitem for passing additional variables through. No workaround is needed in this repo.That fix isn't on the regular feeds yet, so
MicrosoftTestingPlatformVersionis overridden to a build from the testfxtest-toolspreview channel, which the rootNuGet.confignow references. Both should be reverted once a release containing the fix flows to the regular feeds.Pipelines
sdk-diff-tests.ymlandvmr-license-scan.ymlinvokedotnet testdirectly rather than going through Arcade, so their VSTest arguments are translated:--filter "Category=SdkContent"--filter-trait "Category=SdkContent"--filter "FullyQualifiedName=..."--filter-method "..."--logger:'console;verbosity=detailed'--output Detailed--logger:'trx;LogFileName=...'test/Directory.Build.props)MTP has no unified
--filter; the platform itself only provides--filter-uid, and the--filter-class/method/namespace/traitoptions come from xunit.Validation
All five projects build with zero warnings.
-t:Testanddotnet testboth pass, emit trx/xml/html intoartifacts/TestResults, and leave nothing behind next to the test binaries. Verified that an all-skipped project exits 0 while a genuine failure still exits non-zero, and that tests are hosted on the repo-local SDK with noDOTNET_ROOTset in the environment.