Skip to content

[templates] Fix MSTest test-host relaunch. Fixes #26890 - #26898

Open
rolfbjarne wants to merge 2 commits into
mainfrom
dev/rolf/mstest-template-compatibility
Open

rolfbjarne wants to merge 2 commits into
mainfrom
dev/rolf/mstest-template-compatibility

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Updating a generated macOS test project to MSTest 4.5.1 causes dotnet test to fail with a named-pipe handshake error instead of running tests. Since MSTest 4.4.0, TRX reporting uses a controller that relaunches the desktop test host. Our startup code appended reporting options again in the child, causing MTP to reject the duplicate --results-directory; it then discarded MTP's failure exit code.

Preserve incoming arguments and add reporting defaults only when absent, using the same startup logic in all four Apple test templates. Also propagate MTP's nonzero exit codes, use an application-specific temporary results directory when the documents path is empty, and update the templates from MSTest 4.3.2 to 4.5.1.

iOS and tvOS use in-process TRX reporting because MTP explicitly excludes them from controller-backed execution. They share the argument handling for consistency and to honor supplied options.

The upstream behavior change is microsoft/testfx#10808, commit microsoft/testfx@537d6e6.

Regression coverage checks passing and failing tests on all four platforms, plus repeated desktop runs with explicit reporting options, TRX contents, invalid-option exit codes, and the empty-documents fallback. All eight platform cases passed locally; native simulator launches also verified mobile argument forwarding.

Fixes #26890

Note

This pull request description was generated with GitHub Copilot.

🤖 Pull request created by Copilot

rolfbjarne and others added 2 commits October 16, 2026 18:47
MTP relaunches desktop test applications with the reporting options already supplied by the template. Appending those options again causes argument validation to fail, leaving dotnet test unable to complete its named-pipe handshake. Only supply missing defaults on macOS and Mac Catalyst so explicit reporting options survive relaunches.

Update all four Apple test templates to MSTest 4.5.1, preserve nonzero MTP exit codes, and use an application-specific temporary results directory when MyDocuments is empty. This also prevents reporting output from being written relative to the signed app bundle.

Extend the template integration tests to verify actual execution and failed-test exit codes, desktop reporting overrides and repeated launches, command-line error exit codes, and the empty-documents-path fallback.

Fixes #26890

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Forward application command-line arguments to MTP in the iOS and tvOS test templates, and only append reporting defaults when the caller has not supplied them. This keeps startup behavior consistent across all four Apple platforms and preserves explicit test and reporting options.

MTP explicitly disables controller-backed TRX reporting on iOS and tvOS, so these platforms do not need the desktop relaunch workaround themselves. Using the same argument handling nevertheless avoids platform-specific template behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner October 16, 2026 16:49
Copilot AI balanced review requested due to automatic review settings October 16, 2026 16:49

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.

🔵 Needs a closer look

Native relaunch and simulator behavior need Apple-platform validation beyond the evidence available in this review.

1 open finding
What changed in this PR

Fixes MSTest controller relaunch handling in Apple test templates, addressing #26890.

Changes:

  • Preserve incoming arguments and add reporting defaults only when absent.
  • Propagate failure exit codes and provide a temporary results-directory fallback.
  • Upgrade MSTest to 4.5.1 and expand regression coverage.
File Description
tests/​dotnet/​UnitTests/​DotNetTestTest.cs Adds failure, reporting, relaunch, and fallback checks.
dotnet/​Templates/​Microsoft.tvOS.Templates/​tvostest/​csharp/​tvOSTest1.csproj Updates MSTest dependency.
dotnet/​Templates/​Microsoft.tvOS.Templates/​tvostest/​csharp/​Main.cs Updates arguments, results fallback, and exit handling.
dotnet/​Templates/​Microsoft.macOS.Templates/​macostest/​csharp/​Main.cs Fixes relaunch arguments, results fallback, and exit handling.
dotnet/​Templates/​Microsoft.macOS.Templates/​macostest/​csharp/​macOSTest1.csproj Updates MSTest dependency.
dotnet/​Templates/​Microsoft.MacCatalyst.Templates/​maccatalysttest/​csharp/​Main.cs Fixes relaunch arguments, results fallback, and exit handling.
dotnet/​Templates/​Microsoft.MacCatalyst.Templates/​maccatalysttest/​csharp/​MacCatalystTest1.csproj Updates MSTest dependency.
dotnet/​Templates/​Microsoft.iOS.Templates/​iostest/​csharp/​Main.cs Updates arguments, results fallback, and exit handling.
dotnet/​Templates/​Microsoft.iOS.Templates/​iostest/​csharp/​iOSTest1.csproj Updates MSTest dependency.

🧠 Review effort: Balanced

Comment thread tests/dotnet/UnitTests/DotNetTestTest.cs
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: a677502649a39a64a72a96a36178b348fdc001e7 [PR build]

@rolfbjarne rolfbjarne added the backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 label Oct 16, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #a677502] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 221 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 21 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 20 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 20 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Golden Gate (27): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: a677502649a39a64a72a96a36178b348fdc001e7 [PR build]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 copilot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macostest template fails to run when updated to MSTest 4.5.1

3 participants