Skip to content

Fixes #4787. Upgrade all nuget packages including the obsolete xunit v2#4788

Merged
tig merged 33 commits intogui-cs:v2_developfrom
BDisp:v2_4787__upgrade-nuget-packages
Mar 6, 2026
Merged

Fixes #4787. Upgrade all nuget packages including the obsolete xunit v2#4788
tig merged 33 commits intogui-cs:v2_developfrom
BDisp:v2_4787__upgrade-nuget-packages

Conversation

@BDisp
Copy link
Copy Markdown
Collaborator

@BDisp BDisp commented Mar 3, 2026

Fixes

Proposed Changes/Todos

  • Remove all symbols [,) from Directory.Packages.props
  • Rename TestContext to FluentTestContext
  • Fix the generator xunit extensions
  • Fix some code and unit tests

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@BDisp BDisp requested a review from tig as a code owner March 3, 2026 23:27
@tig tig marked this pull request as draft March 3, 2026 23:45
@tig
Copy link
Copy Markdown
Member

tig commented Mar 3, 2026

This is clearly not ready. Why does it touch 190 files?

@tig
Copy link
Copy Markdown
Member

tig commented Mar 3, 2026

Not a fan of "Rename TestContext to FluentTestContext". I chose TextContext carefully. It actually only enabls Fluent sytle as a side-effect.

@BDisp
Copy link
Copy Markdown
Collaborator Author

BDisp commented Mar 3, 2026

This is clearly not ready. Why does it touch 190 files?

Most of the files have been modified because the using Xunit.Abstractions; was removed as it was no longer needed.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (057178b) to head (abf604b).

Files with missing lines Patch % Lines
Terminal.Gui/Drivers/UnixDriver/UnixClipboard.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           v2_develop   #4788       +/-   ##
==============================================
- Coverage       77.62%   0.00%   -77.63%     
==============================================
  Files             463     463               
  Lines           45679   45679               
  Branches         6815    6815               
==============================================
- Hits            35458       0    -35458     
- Misses           8233   45679    +37446     
+ Partials         1988       0     -1988     
Files with missing lines Coverage Δ
Terminal.Gui/Drivers/UnixDriver/UnixClipboard.cs 0.00% <0.00%> (ø)

... and 436 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 057178b...abf604b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BDisp
Copy link
Copy Markdown
Collaborator Author

BDisp commented Mar 3, 2026

Not a fan of "Rename TestContext to FluentTestContext". I chose TextContext carefully. It actually only enabls Fluent sytle as a side-effect.

The name isn't the issue, it can be whatever you want. What's unacceptable is continuing to call it TestContext because xunit.v3 already contains an object with the same name, which creates a conflict. Everything worked fine on my machine. I don't understand why.

Comment thread Tests/TerminalGuiFluentTesting/TestContext.cs Outdated
@BDisp
Copy link
Copy Markdown
Collaborator Author

BDisp commented Mar 4, 2026

Would probably fixes the #4569?

@BDisp BDisp marked this pull request as ready for review March 4, 2026 19:35
@tig
Copy link
Copy Markdown
Member

tig commented Mar 5, 2026

This PR upgraded to xunit.v3 and removed Microsoft.NET.Test.Sdk and xunit.runner.visualstudio, but didn't add the xUnit v3 equivalent for dotnet test integration.

As a result dotnet test no longer works, nor does reshaper testing.

I addition all of the workflow results are bogus because no tests are actually being run:

image

I'm working on a fix now.

tig and others added 2 commits March 5, 2026 12:32
xUnit v3 replaced VSTest with Microsoft Testing Platform (MTP), but
the migration removed the VSTest adapter packages without adding the
MTP configuration. This broke both `dotnet test` (no tests discovered)
and ReSharper test discovery.

- Add `"test": { "runner": "Microsoft.Testing.Platform" }` to
  global.json so `dotnet test` uses MTP (xUnit v3's native runner)
- Add Microsoft.NET.Test.Sdk and xunit.runner.visualstudio packages
  for backward compatibility with IDEs using VSTest (ReSharper, VS
  Test Explorer), per xUnit v3 migration guidance
- Add `<IsTestProject>true</IsTestProject>` to all test projects so
  the .NET SDK and IDEs recognize them as test projects

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BDisp
Copy link
Copy Markdown
Collaborator Author

BDisp commented Mar 5, 2026

I had to remove them all, otherwise it caused errors in the CI pipelines.

@tig
Copy link
Copy Markdown
Member

tig commented Mar 5, 2026

I had to remove them all, otherwise it caused errors in the CI pipelines.

You got rid of the errors in the CI pipelines because no tests were being run! I'm fixing this now.

xUnit v3 uses MTP instead of VSTest. Update all test workflows to use
the MTP-compatible `dotnet test` syntax:

- Use `--project` flag instead of positional path argument
- Replace `--diag` with `--diagnostic-output-directory`
- Replace `--collect:"XPlat Code Coverage" --settings` with `--coverage`
- Remove VSTest-specific flags: `--blame`, `--blame-crash`,
  `--blame-hang`, `--blame-hang-timeout`, `--blame-crash-collect-always`
- Remove `-- xUnit.*` pass-through args (not supported in MTP)
- Remove `VSTEST_DUMP_PATH` env var and VSTest process exclusions
- Update README to reflect MTP changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BDisp
Copy link
Copy Markdown
Collaborator Author

BDisp commented Mar 5, 2026

You got rid of the errors in the CI pipelines because no tests were being run! I'm fixing this now.

Sorry, I didn't even notice that. Thanks.

xunit.v3 now creates executable files (.exe) for Windows and files without an extension for Linux/Mac.

tig and others added 4 commits March 5, 2026 12:49
xUnit v3 test projects are standalone executables. On Linux/macOS,
the app host binaries lose execute permissions when uploaded/downloaded
as build artifacts, causing "Permission denied" when MTP tries to
launch them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The --coverage flag requires Microsoft.Testing.Extensions.CodeCoverage
which is not included. Remove coverage collection and the Linux-only
branching it required. Also remove Codecov upload steps (coverage can
be re-added later with a compatible solution). Fix missing chmod step
in parallel_unittests job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MTP runs the native app host executable directly (unlike VSTest which
used dotnet exec on the .dll). Linux-built app hosts can't run on
macOS/Windows, causing "Exec format error".

Each OS now builds its own binaries instead of downloading shared
artifacts from a single Linux build. This removes the quick-build
dependency, artifact download, and chmod workarounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tig
Copy link
Copy Markdown
Member

tig commented Mar 5, 2026

Ok, I think this is good now. You should double check my work.

@tig tig requested a review from Copilot March 5, 2026 20:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Upgrades the repo’s NuGet dependencies (notably moving from xUnit v2 → xUnit v3) and updates the test/tooling infrastructure to match, including renaming the fluent testing helper library and adjusting CI workflows.

Changes:

  • Migrate test projects and helper attributes to xUnit v3 APIs and update many tests accordingly.
  • Rename/move fluent testing helpers to AppTestHelpers (+ generator + integration test updates).
  • Update CLI parsing in examples (System.CommandLine) and simplify GitHub Actions test workflows.

Reviewed changes

Copilot reviewed 210 out of 213 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
global.json Adds test runner configuration (Microsoft.Testing.Platform).
Directory.Packages.props Updates central package versions (xUnit v3, tooling, logging, etc.).
.github/workflows/unit-tests.yml Switches CI to build in-job and run tests with diagnostic output.
.github/workflows/stress-tests.yml Updates stress test invocation and diagnostic collection.
.github/workflows/integration-tests.yml Updates integration test invocation and diagnostic collection.
.github/workflows/README.md Updates workflow documentation to match new invocation patterns.
Terminal.sln Renames solution projects to AppTestHelpers*.
Terminal.Gui/Terminal.Gui.csproj Updates InternalsVisibleTo to the renamed helper assembly.
Terminal.Gui/Drivers/UnixDriver/UnixClipboard.cs Converts ctor body to expression-bodied assignment.
Terminal.Gui/Drivers/Input/IInput.cs Updates docs to reference AppTestHelper.
Terminal.Gui/App/Clipboard/ClipboardProcessRunner.cs Adds early-return behavior when console I/O is redirected.
Examples/UICatalog/UICatalog.cs Migrates System.CommandLine setup/handlers to newer APIs.
Examples/UICatalog/Scenarios/Editor.cs Switches checkbox handlers from ValueChanging to ValueChanged and adjusts culture changes.
Examples/ScenarioRunner/Program.cs Migrates ScenarioRunner CLI to newer System.CommandLine APIs.
Examples/ReactiveExample/Program.cs Reworks ReactiveUI setup to use builder API.
Examples/ReactiveExample/LoginView.cs Uses scheduler from builder rather than RxApp.MainThreadScheduler.
Tests/UnitTestsParallelizable/UnitTests.Parallelizable.csproj Updates packages to xUnit v3 + runner, adjusts test project properties and references.
Tests/UnitTests/UnitTests.csproj Updates packages to xUnit v3 + runner, adjusts test project properties and references.
Tests/IntegrationTests/IntegrationTests.csproj Updates packages and references to AppTestHelpers*.
Tests/StressTests/StressTests.csproj Updates packages to xUnit v3 and adjusts test project settings.
Tests/TerminalGuiFluentTestingXunit/XunitContextExtensions.cs Moves xUnit fluent helper extensions into AppTestHelpers.XunitHelpers.
Tests/TerminalGuiFluentTestingXunit/TerminalGuiFluentTestingXunit.csproj Renames/moves project references and updates packages (xUnit v3).
Tests/TerminalGuiFluentTestingXunit.Generator/TheGenerator.cs Updates generator namespaces/usings and generated method bodies for renamed helper context.
Tests/TerminalGuiFluentTesting/With.cs Renames namespace/types from TerminalGuiFluentTestingAppTestHelpers.
Tests/TerminalGuiFluentTesting/ThreadSafeStringWriter.cs Renames namespace to AppTestHelpers.
Tests/TerminalGuiFluentTesting/TextWriterLoggerProvider.cs Renames namespace to AppTestHelpers.
Tests/TerminalGuiFluentTesting/TextWriterLogger.cs Renames namespace to AppTestHelpers.
Tests/TerminalGuiFluentTesting/TestDriver.cs Renames namespace to AppTestHelpers.
Tests/TerminalGuiFluentTesting/TestContext.cs Renames TestContextAppTestHelper and adjusts fluent API return types.
Tests/TerminalGuiFluentTesting/TestContext.ViewBase.cs Updates partial class + fluent method return types to AppTestHelper.
Tests/TerminalGuiFluentTesting/TestContext.Navigation.cs Updates partial class + fluent method return types to AppTestHelper.
Tests/TerminalGuiFluentTesting/TestContext.Input.cs Updates partial class + fluent method return types to AppTestHelper.
Tests/TerminalGuiFluentTesting/TestContext.ContextMenu.cs Updates partial class + fluent method return types to AppTestHelper.
Tests/IntegrationTests/FluentTests/TreeViewTests.cs Updates integration tests to use AppTestHelper and new helper namespaces.
Tests/IntegrationTests/FluentTests/TextFieldTests.cs Updates integration tests to use AppTestHelper and new helper namespaces.
Tests/IntegrationTests/FluentTests/TestContextTests.cs Updates integration tests/docs to AppTestHelper.
Tests/IntegrationTests/FluentTests/TestContextMouseEventTests.cs Updates integration tests/docs to AppTestHelper.
Tests/IntegrationTests/FluentTests/TestContextKeyEventTests.cs Updates integration tests/docs to AppTestHelper.
Tests/IntegrationTests/FluentTests/PopverMenuTests.cs Updates integration tests to use AppTestHelper and new helper namespaces.
Tests/IntegrationTests/FluentTests/NavigationTests.cs Updates integration tests to use AppTestHelper.
Tests/IntegrationTests/FluentTests/MenuBarTests.cs Updates integration tests to use AppTestHelper and new helper namespaces.
Tests/IntegrationTests/FluentTests/LinearRangeFluentTests.cs Updates integration tests to use AppTestHelper.
Tests/IntegrationTests/FluentTests/FileDialogTests.cs Updates integration tests to use AppTestHelper and new helper namespaces.
Tests/UnitTestsParallelizable/TestDateAttribute.cs Migrates BeforeAfterTestAttribute usage to xUnit v3 signature.
Tests/UnitTests/TestRespondersDisposedAttribute.cs Migrates BeforeAfterTestAttribute usage to xUnit v3 signature.
Tests/UnitTests/SetupFakeApplicationAttribute.cs Migrates BeforeAfterTestAttribute usage to xUnit v3 signature.
Tests/UnitTests/AutoInitShutdownAttribute.cs Migrates BeforeAfterTestAttribute usage to xUnit v3 signature.
Tests/UnitTests/Views/TextViewTests.cs Updates xUnit attribute hooks to xUnit v3 signatures.
Tests/UnitTests/Views/TextFieldTests.cs Updates xUnit attribute hooks to xUnit v3 signatures.
Tests/UnitTests/Views/LabelTests.cs Updates nullability for Record.Exception result.
Tests/UnitTestsParallelizable/** (many files) Primarily removes Xunit.Abstractions usings and updates async/task usage to flow cancellation tokens via TestContext.Current.CancellationToken.
Comments suppressed due to low confidence (2)

Tests/UnitTestsParallelizable/ViewBase/Keyboard/AutoHotKeyAssignmentTests.cs:1

  • This test mutates Thread.CurrentThread.CurrentUICulture but doesn’t restore it. In a parallel test suite, that can leak state into other tests running on the same thread later. Wrap the change in a try/finally (restore previous culture), or use a scoped helper/attribute that guarantees restoration.
    Tests/UnitTests/UnitTests.csproj:1
  • xunit.runner.visualstudio is usually marked with PrivateAssets="all" (and a constrained IncludeAssets) to avoid it flowing transitively and to keep it clearly test-only. Consider restoring the previous PrivateAssets/IncludeAssets block (same applies to other test projects updated similarly).

Comment thread Examples/UICatalog/UICatalog.cs Outdated
Comment thread Examples/ScenarioRunner/Program.cs
Comment thread .github/workflows/stress-tests.yml Outdated
Comment thread .github/workflows/README.md Outdated
Comment thread .github/workflows/README.md Outdated
Comment thread .github/workflows/README.md Outdated
Comment thread Directory.Packages.props Outdated
Comment thread Directory.Packages.props Outdated
Comment thread Terminal.Gui/App/Clipboard/ClipboardProcessRunner.cs
Update dotnet test commands across all documentation to use --project
flag (required by Microsoft Testing Platform). Also update README to
reflect per-OS builds and replace --blame references with --diagnostic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tig
Copy link
Copy Markdown
Member

tig commented Mar 5, 2026

Fix: dotnet test and ReSharper test discovery broken after xUnit v3 upgrade

What was wrong

The xUnit v3 upgrade replaced VSTest with Microsoft Testing Platform (MTP) but didn't update the project configuration or CI workflows to account for the differences:

  1. dotnet test found zero tests — xUnit v3 removed Microsoft.NET.Test.Sdk and xunit.runner.visualstudio (the VSTest adapter). Without these, dotnet test couldn't discover any tests. The .NET SDK also requires <IsTestProject>true</IsTestProject> to recognize test projects when Microsoft.NET.Test.Sdk is absent.

  2. ReSharper couldn't discover tests — ReSharper uses VSTest for test discovery, which requires Microsoft.NET.Test.Sdk and xunit.runner.visualstudio.

  3. CI workflows used VSTest-specific syntaxdotnet test with MTP requires --project instead of positional paths, doesn't support --blame* flags, --coverage requires an extra package, and --diagnostic-output-directory requires --diagnostic.

  4. Cross-platform CI was broken — The old workflow built once on Linux and shared artifacts across OSes. MTP runs the native app host executable directly (unlike VSTest which used dotnet exec on the .dll), so Linux-built ELF binaries can't run on macOS/Windows.

What was fixed

  • global.json: Added "test": { "runner": "Microsoft.Testing.Platform" } to enable MTP for dotnet test (required for .NET 10 SDK)
  • Directory.Packages.props: Added Microsoft.NET.Test.Sdk 18.3.0 and xunit.runner.visualstudio 3.1.5 for backward compatibility with IDEs (per xUnit v3 migration guidance)
  • All test .csproj files: Added <IsTestProject>true</IsTestProject>, Microsoft.NET.Test.Sdk, and xunit.runner.visualstudio package references
  • CI workflows: Updated to MTP syntax (--project, --diagnostic, removed --blame*/--coverage), each OS now builds locally instead of sharing cross-platform artifacts
  • All documentation: Updated dotnet test commands across 9 markdown files

tig and others added 4 commits March 5, 2026 13:42
- Fix duplicate --diagnostic in stress-tests.yml
- Update CONTRIBUTING.md, testing-patterns.md, and pr-workflow.md to
  note that coverage collection is temporarily disabled during the
  xUnit v3 / MTP migration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator Author

@BDisp BDisp left a comment

Choose a reason for hiding this comment

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

Well done. Thanks for your help.

@tig tig merged commit c307f89 into gui-cs:v2_develop Mar 6, 2026
11 checks passed
@tig
Copy link
Copy Markdown
Member

tig commented Mar 6, 2026

Well done. Thanks for your help.

Thank you for taking this on... getting to xunit3 felt daunting to me. It's great having it done.

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.

Upgrade all nuget packages including the obsolete xunit v2

3 participants