Repository navigation
[templates] Fix MSTest test-host relaunch. Fixes #26890 - #26898
rolfbjarne wants to merge 2 commits into
Conversation
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>
There was a problem hiding this comment.
🔵 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
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [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 macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |

Updating a generated macOS test project to MSTest 4.5.1 causes
dotnet testto 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