Repository navigation
Move test projects to xUnit v3 (#4671) - #4686
Merged
Merged
Conversation
- Migrate test packages from xunit v2 to xunit.v3 and runner 4.0 - Set OutputType to Exe for all test projects per xUnit v3 stand-alone executable model - Update .NET Framework test target from net471 to net472 in AutoMapper.UnitTests - Clean up src/UnitTests/App.config by removing xunit.appDomain and stale nunit binding redirects - Remove #if !NETFRAMEWORK from InvalidSignature_LogsCopyPasteHint_WithoutExceptionDetails in LicenseAccessorTests - Add RunConfiguration.TreatNoTestsAsError=true to Build.ps1 test execution to fail if no tests are discovered
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The xUnit v3 upgrade leaves integration-test fixtures using incompatible Task-returning lifetime methods, preventing the project from compiling until initialization and disposal signatures are updated.
1 open issue
What changed in this PR
This PR migrates AutoMapper’s test projects to xUnit v3 to address .NET Framework binding-redirect issues described in #4671.
Changes:
- Updates xUnit packages and configures all three test projects as executables.
- Raises the unit-test .NET Framework target to 4.7.2, cleans up legacy configuration, and re-enables the signature-validation test.
- Configures CI test runs to fail when no tests are discovered.
| File | Description |
|---|---|
| src/UnitTests/Licensing/LicenseAccessorTests.cs | Enables the invalid-signature test on .NET Framework. |
| src/UnitTests/AutoMapper.UnitTests.csproj | Adopts xUnit v3, executable output, and net472. |
| src/UnitTests/App.config | Removes obsolete settings and updates the supported runtime. |
| src/IntegrationTests/AutoMapper.IntegrationTests.csproj | Adopts xUnit v3 and executable output. |
| src/AutoMapper.DI.Tests/AutoMapper.DI.Tests.csproj | Adopts xUnit v3 and executable output. |
| Directory.Packages.props | Updates centrally managed xUnit package versions. |
| Build.ps1 | Treats zero discovered tests as an error. |
Review effort: Balanced
- Use xunit.v3.mtp-off so the VSTest-based dotnet test in Build.ps1 keeps working on the .NET 10+ SDK (xunit.v3 4.x defaults to MTP v2) - Implement IAsyncLifetime with ValueTask in integration test fixtures - Replace obsolete CollectionBehavior(DisableTestParallelization) with Parallelization(Mode = ParallelMode.None) - Pass TestContext.Current.CancellationToken where xUnit1051 requires it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Opt into the MTP dotnet test experience via global.json - Use xunit.v3 (MTP v2) instead of xunit.v3.mtp-off; drop Microsoft.NET.Test.Sdk and xunit.runner.visualstudio - Add Microsoft.Testing.Extensions.TrxReport for TRX output - Update Build.ps1 to the MTP dotnet test syntax; skip the merged TRX so the test reporter doesn't count results twice. MTP fails on zero tests by default, replacing TreatNoTestsAsError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The test command uses an option unsupported by CI’s .NET 11 SDK, causing test execution to fail, while the Windows-style artifacts path also causes Linux TRX reports to be missed during upload.
3 open issues
Review effort: Balanced
On Linux, ".\artifacts" is passed to dotnet test as a literal directory name, so TRX files landed outside artifacts/ and the CI upload glob missed them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.


Closes #4671
Summary of Changes
This PR migrates the test projects in AutoMapper from xUnit v2 to xUnit v3, fulfilling all items in Jimmy Bogard's checklist in #4671:
et471 to
et472 (supported by xUnit v3); the core AutoMapper library continues targeting
et471.
unit.framework binding redirects.