Skip to content

chore: Update test projects to use xunit v3#3065

Draft
filzrev wants to merge 21 commits intodotnet:masterfrom
filzrev:chore-update-tests-to-xunit-v3
Draft

chore: Update test projects to use xunit v3#3065
filzrev wants to merge 21 commits intodotnet:masterfrom
filzrev:chore-update-tests-to-xunit-v3

Conversation

@filzrev
Copy link
Copy Markdown
Contributor

@filzrev filzrev commented Mar 30, 2026

This PR migrate test projects to use Microsoft.Testing.Platform (xUnit.v3 and TUnit)

What's changed in this PR

1. Update test projects

  • Migrate project to use xUnit v3 and MTP v2 (`xunit.v3.mtp-v2)
  • Change OutputType to Exe
  • Remove Microsoft.NET.Test.Sdk and xunit.runner.visualstudio packages

2. Modify namespaces
Remove Xunit.Abstractions namespace and add additional using.

3. Modify FactEnvSpecificAttribute/TheoryEnvSpecificAttribute
It's required to resolve xUnit3003 analyzer errors

4. Remove Tests project dependency from IntegrationTests.
Instead, add <Compile> file references.

5. Modify TheoryData related codes.
Modify incompatible code between xUnit v2/v3.

6. Add global.json at solution root
It's required to run tests with Microsoft.Testing.Platform with dotnet test

7. Add tests/.editorconfig‎
It's required to suppress following warnings.

xUnit1051: Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

8. Modify InlineDataEnvSpecific.cs and remove InlineDataEnvSpecificDiscoverer.cs
xUnit v3 don't support reflection based discover and needs migrate code.
https://xunit.net/docs/getting-started/v3/migration#removal-of-reflection-abstractions

9. Fix Wasm related tests
After migrated to xUnit.v3 some Wasm related tests failed by AppHost check.
So it need to add workaround code by adding Directory.Build.targets file.

10. Add settings to suppress warning MSB3277

11. Modify BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj‎
Migrate test framework to use TUnit.
It's required because xUnit v3 don't support .NET 4.6.2.
And It can't mix VsTest/MTP based projects

12. Update BenchmarkDotNet.Build project

  • Update Cake.Frosting package
  • Add PathType = DotNetTestPathType.Auto option. Because when using dotnet test with MTP mode. It need explicitly specify --project.
  • Modify logger parameters for trx.

13. Disable IsTestingPlatformApplication property for auto-generated project templates

When Microsoft.Testing.Platform.MSBuild package is referenced transitively.
It auto-generate Main entry point by default and cause conflicts.
So it need to suppress auto-generated entry point.

14. Modify run-tests-selected workflow to support dotnet test with MTP

15. Add <PreferNativeArm64> setting for .NET Framework tests on windows-11-arm
When migrated tests to MTP and run tests with dotnet test.
It seems x64 emulation is used by default.
So it need enable <PreferNativeArm64> setting to keep existing behaviors.

TODO:

  • Add testconfig.json
  • Migrate VSTestAdapter project to use MTP (It's implemented on another PR)
  • Failed to run macos tests (Timeout)
  • Update generate-coverage-report.yaml filters

@filzrev filzrev force-pushed the chore-update-tests-to-xunit-v3 branch 2 times, most recently from 6104248 to 262ca3e Compare March 30, 2026 22:33
@filzrev filzrev force-pushed the chore-update-tests-to-xunit-v3 branch from 6bea07d to 47b304b Compare April 1, 2026 13:55
@filzrev filzrev force-pushed the chore-update-tests-to-xunit-v3 branch from 47b304b to 9af1831 Compare April 1, 2026 14:05
@filzrev filzrev force-pushed the chore-update-tests-to-xunit-v3 branch from dab3375 to a9fe929 Compare April 3, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant