Skip to content

Move test projects to xUnit v3 (#4671) - #4686

Merged
jbogard merged 4 commits into
LuckyPennySoftware:mainfrom
SkyDevLab:migrate-xunit-v3
Nov 30, 2026
Merged

jbogard merged 4 commits into
LuckyPennySoftware:mainfrom
SkyDevLab:migrate-xunit-v3

Conversation

@SkyDevLab

Copy link
Copy Markdown
Contributor

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:

  • Migrate to xUnit v3:
    • Updated Directory.Packages.props to reference xunit.v3 (4.0.3) and xunit.runner.visualstudio (4.0.1).
    • Configured Exe in all test projects (AutoMapper.UnitTests.csproj, AutoMapper.IntegrationTests.csproj, and AutoMapper.DI.Tests.csproj) per the xUnit v3 stand-alone executable model.
  • Update .NET Framework test target:
    • Raised .NET Framework target for AutoMapper.UnitTests from
      et471 to
      et472 (supported by xUnit v3); the core AutoMapper library continues targeting
      et471.
  • Clean up src/UnitTests/App.config:
    • Removed xunit.appDomain setting and obsolete
      unit.framework binding redirects.
  • Enable .NET Framework test execution in LicenseAccessorTests:
    • Removed #if !NETFRAMEWORK around InvalidSignature_LogsCopyPasteHint_WithoutExceptionDetails. Since xUnit v3 runs tests in the test project's own executable process, AutoMapper.UnitTests.exe.config and binding redirects apply cleanly on .NET Framework.
  • Fail CI when zero tests are discovered:
    • Added -- RunConfiguration.TreatNoTestsAsError=true to Build.ps1 so that any test run failing to discover tests will return a non-zero exit code and fail the build.

@CLAassistant

CLAassistant commented Nov 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

- 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

jbogard and others added 2 commits November 30, 2026 10:05
- 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread Build.ps1 Resolved
Comment thread Build.ps1 Resolved
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>
@jbogard
jbogard merged commit 586532c into LuckyPennySoftware:main Nov 30, 2026
3 checks passed
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.

Move test projects to xUnit v3

4 participants