Add target framework to default TRX file name - #15565
Conversation
There was a problem hiding this comment.
Pull request overview
Prevents TRX files from being overwritten in multi-target (multi-TFM) test runs by including the target framework in the default, auto-generated TRX filename (matching the existing LogFilePrefix behavior).
Changes:
- Append target framework short name (e.g.,
net10.0) to the default TRX file base name whenTargetFrameworkis available. - Add unit tests to validate default TRX naming with and without a target framework.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs | Adds coverage ensuring default TRX filenames include TFM (when provided) and still work without it. |
| src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs | Updates default TRX filename generation to append the framework short name when present. |
Amaury Levé (Evangelink)
left a comment
There was a problem hiding this comment.
LGTM. Small, well-scoped change that correctly aligns the default TRX filename behavior with the existing LogFilePrefix path. The consistency table tells the story:
| Path | TFM before PR | TFM after PR |
|---|---|---|
LogFileName (explicit) |
n/a | n/a |
LogFilePrefix |
✅ | ✅ |
| Default (auto-generated) | ❌ | ✅ |
Left a couple of optional nits (whitespace guard, fallback test) but nothing blocking.
3267b32 to
1bd7c84
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/TrxLoggerTests.cs:3
Assert.Contains/Assert.EndsWithare not MSTest string assertions in many MSTest versions (and can even bind to the wrong overloads, e.g., treating the string as IEnumerable). To make these tests robust and unambiguous, useStringAssert.Contains(...)/StringAssert.EndsWith(...)(orAssert.IsTrue(fileName.Contains(...))/Assert.IsTrue(fileName.EndsWith(...))) with the same messages.
When running multi-TFM tests, TRX files were overwritten because the default filename did not include the target framework. The TFM was already appended when using the LogFilePrefix parameter, but not for the default auto-generated filename. This change appends the framework short name (e.g. net10.0) to the default TRX filename, matching the existing behavior for LogFilePrefix. Before: username_MACHINE_2026-03-24_07_51_08.trx After: username_MACHINE_2026-03-24_07_51_08_net10.0.trx Closes microsoft#15506 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Guard against empty/whitespace framework with IsNullOrWhiteSpace - Add test for custom framework string fallback (SomeCustomFramework) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1bd7c84 to
46fe387
Compare
| public void DefaultTrxFileNameShouldUseRawStringWhenFrameworkCannotBeParsed() | ||
| { | ||
| _parameters.Remove(TrxLoggerConstants.LogFileNameKey); | ||
| _parameters[DefaultLoggerParameterNames.TargetFramework] = "SomeCustomFramework"; | ||
| _testableTrxLogger.Initialize(_events.Object, _parameters); |
There was a problem hiding this comment.
New behavior uses the raw TargetFramework string when parsing fails, but there’s no test coverage for raw values containing characters that are invalid in filenames or path separators (e.g., Some/Framework, ..\\x, net10.0:custom). Adding a unit test for sanitization (or expected failure behavior) would prevent regressions and validate safe filename handling.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8a9287e to
55c6505
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| [TestMethod] | ||
| public void DefaultTrxFileNameShouldWorkWithoutFramework() | ||
| { | ||
| _parameters.Remove(TrxLoggerConstants.LogFileNameKey); |
There was a problem hiding this comment.
This test is intended to verify behavior when no framework is available, but it doesn’t explicitly clear DefaultLoggerParameterNames.TargetFramework. If _parameters is reused across tests (or pre-populated in setup), the test may not actually exercise the no-framework path. Consider removing DefaultLoggerParameterNames.TargetFramework (and/or asserting the filename does NOT contain a _<tfm> suffix) to make the scenario deterministic.
| _parameters.Remove(TrxLoggerConstants.LogFileNameKey); | |
| _parameters.Remove(TrxLoggerConstants.LogFileNameKey); | |
| _parameters.Remove(DefaultLoggerParameterNames.TargetFramework); |
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) | `18.5.1` → `18.6.0` |  |  | --- ### Release Notes <details> <summary>microsoft/vstest (Microsoft.NET.Test.Sdk)</summary> ### [`v18.6.0`](https://github.com/microsoft/vstest/releases/tag/v18.6.0) #### What's Changed - Revert removal of Video Recorder by [@​nohwnd](https://github.com/nohwnd) in [#​15336](microsoft/vstest#15336) - Speed up blame by filtering non-.NET processes from dump collection by [@​nohwnd](https://github.com/nohwnd) in [#​15518](microsoft/vstest#15518) - Add README.md to NuGet packages by [@​nohwnd](https://github.com/nohwnd) in [#​15550](microsoft/vstest#15550) - Report child process info on connection timeout by [@​nohwnd](https://github.com/nohwnd) in [#​15603](microsoft/vstest#15603) ##### Changes to tests and infra - Brand as 18.6 by [@​nohwnd](https://github.com/nohwnd) in [#​15423](microsoft/vstest#15423) - Upgrading code coverage version to 18.5.1, by [@​fhnaseer](https://github.com/fhnaseer) in [#​15422](microsoft/vstest#15422) - Updating System.Collections.Immutable to 9.0.11 by [@​MSLukeWest](https://github.com/MSLukeWest) in [#​15425](microsoft/vstest#15425) - Fix attachVS when used for debugging integration tests by [@​nohwnd](https://github.com/nohwnd) in [#​15451](microsoft/vstest#15451) - Replace dotnet.config, with global.json by [@​nohwnd](https://github.com/nohwnd) in [#​15449](microsoft/vstest#15449) - Document debugging integration tests with AttachVS by [@​Copilot](https://github.com/Copilot) in [#​15452](microsoft/vstest#15452) - Fix stack overflow tests by [@​nohwnd](https://github.com/nohwnd) in [#​15461](microsoft/vstest#15461) - Make TestAssets.sln buildable locally by [@​Youssef1313](https://github.com/Youssef1313) in [#​15466](microsoft/vstest#15466) - Try filtering out tests by [@​nohwnd](https://github.com/nohwnd) in [#​15463](microsoft/vstest#15463) - Build just once when tfms run in parallel by [@​nohwnd](https://github.com/nohwnd) in [#​15465](microsoft/vstest#15465) - Review simplify compatibility sources, deduplicate tests by [@​nohwnd](https://github.com/nohwnd) in [#​15472](microsoft/vstest#15472) - Cleanup dead TRX code by [@​Youssef1313](https://github.com/Youssef1313) in [#​15474](microsoft/vstest#15474) - Update .NET runtimes to 8.0.25, 9.0.14, and 10.0.4 by [@​nohwnd](https://github.com/nohwnd) in [#​15481](microsoft/vstest#15481) - Compat matrix checker by [@​nohwnd](https://github.com/nohwnd) in [#​15480](microsoft/vstest#15480) - Add trx analysis skill by [@​nohwnd](https://github.com/nohwnd) in [#​15486](microsoft/vstest#15486) - Split integration tests to single tfm and multi tfm project by [@​nohwnd](https://github.com/nohwnd) in [#​15484](microsoft/vstest#15484) - Update matrix by [@​nohwnd](https://github.com/nohwnd) in [#​15477](microsoft/vstest#15477) - Break infinite restore loop in VS by [@​nohwnd](https://github.com/nohwnd) in [#​15503](microsoft/vstest#15503) - Use global package cache for build, and local for running integration tests by [@​nohwnd](https://github.com/nohwnd) in [#​15500](microsoft/vstest#15500) - Update contributing by [@​nohwnd](https://github.com/nohwnd) in [#​15505](microsoft/vstest#15505) - Reduce test wall-clock time by increasing minThreads by [@​drognanar](https://github.com/drognanar) in [#​15502](microsoft/vstest#15502) - Indicator flakiness by [@​nohwnd](https://github.com/nohwnd) in [#​15513](microsoft/vstest#15513) - Fix ci build by [@​nohwnd](https://github.com/nohwnd) in [#​15515](microsoft/vstest#15515) - Fix thread safety issues by [@​Evangelink](https://github.com/Evangelink) in [#​15512](microsoft/vstest#15512) - Optimize DotnetSDKSimulation\_PostProcessing test (163s → 61s) by [@​nohwnd](https://github.com/nohwnd) in [#​15516](microsoft/vstest#15516) - Build isolated test assets for single TFM instead of 7 by [@​nohwnd](https://github.com/nohwnd) in [#​15517](microsoft/vstest#15517) - Remove unused dependencies from Library.IntegrationTests by [@​nohwnd](https://github.com/nohwnd) in [#​15527](microsoft/vstest#15527) - Remove printing \_attachments content to console by [@​nohwnd](https://github.com/nohwnd) in [#​15520](microsoft/vstest#15520) - Add Linux/macOS test filtering guide to CONTRIBUTING.md by [@​nohwnd](https://github.com/nohwnd) in [#​15521](microsoft/vstest#15521) - Change integration test parallelization from ClassLevel to MethodLevel by [@​nohwnd](https://github.com/nohwnd) in [#​15526](microsoft/vstest#15526) - Unify target framework checks with IsNetFrameworkTarget/IsNetTarget by [@​nohwnd](https://github.com/nohwnd) in [#​15523](microsoft/vstest#15523) - Add unattended work instructions to copilot-instructions.md by [@​nohwnd](https://github.com/nohwnd) in [#​15531](microsoft/vstest#15531) - Reduce code style rule severity from warning to suggestion by [@​nohwnd](https://github.com/nohwnd) in [#​15522](microsoft/vstest#15522) - Remove Debug/Release line number branching from tests by [@​nohwnd](https://github.com/nohwnd) in [#​15519](microsoft/vstest#15519) - Revise unattended work instructions in copilot-instructions.md by [@​nohwnd](https://github.com/nohwnd) in [#​15532](microsoft/vstest#15532) - Improve CompatibilityRowsBuilder error message with diagnostic details by [@​nohwnd](https://github.com/nohwnd) in [#​15529](microsoft/vstest#15529) - docs: add git worktree and upstream sync workflow to copilot-instructions.md by [@​nohwnd](https://github.com/nohwnd) in [#​15538](microsoft/vstest#15538) - Add VSIX runner to smoke tests by [@​nohwnd](https://github.com/nohwnd) in [#​15541](microsoft/vstest#15541) - Remove deprecated WebTest and TMI test methods by [@​nohwnd](https://github.com/nohwnd) in [#​15525](microsoft/vstest#15525) - Fix compatibility test failures for legacy vstest.console and MSTest adapter by [@​nohwnd](https://github.com/nohwnd) in [#​15534](microsoft/vstest#15534) - Convert TestPlatform.sln to slnx format by [@​nohwnd](https://github.com/nohwnd) in [#​15551](microsoft/vstest#15551) - Convert test/TestAssets .sln files to .slnx format by [@​nohwnd](https://github.com/nohwnd) in [#​15557](microsoft/vstest#15557) - Enable parallelization for blame data collector tests by [@​nohwnd](https://github.com/nohwnd) in [#​15552](microsoft/vstest#15552) - Fix CI failure when GeneratedTestAssets directory doesn't exist by [@​nohwnd](https://github.com/nohwnd) in [#​15556](microsoft/vstest#15556) - Set DOTNET\_ROOT in test.sh for local Linux usage by [@​nohwnd](https://github.com/nohwnd) in [#​15559](microsoft/vstest#15559) - Use MSTest recommended analyzers by [@​Evangelink](https://github.com/Evangelink) in [#​15539](microsoft/vstest#15539) - Document semicolon handling in RunSettings test parameters by [@​nohwnd](https://github.com/nohwnd) in [#​15561](microsoft/vstest#15561) - Enable CA1067 analyzer and fix violations by [@​nohwnd](https://github.com/nohwnd) in [#​15560](microsoft/vstest#15560) - Fix HTML logger parallel file collision with atomic file creation by [@​nohwnd](https://github.com/nohwnd) in [#​15562](microsoft/vstest#15562) - Deduplicate package extraction between verify-nupkgs and IntegrationTestBuild by [@​nohwnd](https://github.com/nohwnd) in [#​15554](microsoft/vstest#15554) - Fix MSTEST0046: use Assert.MatchesRegex instead of StringAssert.Matches by [@​nohwnd](https://github.com/nohwnd) in [#​15575](microsoft/vstest#15575) - Attach diagnostic logs to acceptance test runs by [@​nohwnd](https://github.com/nohwnd) in [#​15572](microsoft/vstest#15572) - Deprecate EnableShutdownAfterTestRun which is no-op by [@​Youssef1313](https://github.com/Youssef1313) in [#​15576](microsoft/vstest#15576) - Skip VideoRecorder test on CI due to access denied errors by [@​nohwnd](https://github.com/nohwnd) in [#​15587](microsoft/vstest#15587) - Fix integration test build collision with mutex + EventWaitHandle by [@​nohwnd](https://github.com/nohwnd) in [#​15568](microsoft/vstest#15568) - Reduce blame test flakiness: increase hang dump timeout to 10s by [@​nohwnd](https://github.com/nohwnd) in [#​15590](microsoft/vstest#15590) - Fix concurrent modification in MetricsCollection by [@​nohwnd](https://github.com/nohwnd) in [#​15581](microsoft/vstest#15581) - Fix PassingNoArguments test: disable --diag to preserve help output by [@​nohwnd](https://github.com/nohwnd) in [#​15583](microsoft/vstest#15583) - perf: fix dictionary double-lookups, Collection.Contains, and LINQ allocations by [@​Evangelink](https://github.com/Evangelink) in [#​15533](microsoft/vstest#15533) - Replace VSSDK-sourced DLLs with proper package references by [@​nohwnd](https://github.com/nohwnd) in [#​15567](microsoft/vstest#15567) - Add target framework to default TRX file name by [@​nohwnd](https://github.com/nohwnd) in [#​15565](microsoft/vstest#15565) - Update post-build template parameters by [@​nohwnd](https://github.com/nohwnd) in [#​15591](microsoft/vstest#15591) - Fix path for post-build template and adjust validation by [@​nohwnd](https://github.com/nohwnd) in [#​15592](microsoft/vstest#15592) - Add azure-pipelines-official.yml to pipeline files by [@​nohwnd](https://github.com/nohwnd) in [#​15594](microsoft/vstest#15594) - Update comment formatting for signing validation by [@​nohwnd](https://github.com/nohwnd) in [#​15597](microsoft/vstest#15597) - Fix enable-auto-merge for maestro by [@​Youssef1313](https://github.com/Youssef1313) in [#​15595](microsoft/vstest#15595) - Auto-approve maestro PRs by [@​Youssef1313](https://github.com/Youssef1313) in [#​15598](microsoft/vstest#15598) - Update enable-auto-merge to squash by [@​Youssef1313](https://github.com/Youssef1313) in [#​15602](microsoft/vstest#15602) - Update enable-auto-merge.yml for the correct permissions by [@​Youssef1313](https://github.com/Youssef1313) in [#​15606](microsoft/vstest#15606) - Add 365 regression tests for untested bug fixes by [@​nohwnd](https://github.com/nohwnd) in [#​15615](microsoft/vstest#15615) - Fix typos and add comments to empty catch blocks by [@​nohwnd](https://github.com/nohwnd) in [#​15609](microsoft/vstest#15609) - Fix flaky EventLogCollector test: ensure deterministic event log entries by [@​nohwnd](https://github.com/nohwnd) in [#​15607](microsoft/vstest#15607) - Mark PathConverter tests as Windows-only by [@​nohwnd](https://github.com/nohwnd) in [#​15617](microsoft/vstest#15617) - Fix HangDumpOnTimeout flakiness and ignore VideoRecorder test by [@​nohwnd](https://github.com/nohwnd) in [#​15616](microsoft/vstest#15616) - Add copilot-setup-steps.yml by [@​nohwnd](https://github.com/nohwnd) in [#​15604](microsoft/vstest#15604) - Add CreateNoNewWindow RunConfiguration setting by [@​nohwnd](https://github.com/nohwnd) in [#​15585](microsoft/vstest#15585) - Add preview packages documentation by [@​nohwnd](https://github.com/nohwnd) in [#​15628](microsoft/vstest#15628) - Cleanup filter implementation by [@​Youssef1313](https://github.com/Youssef1313) in [#​15629](microsoft/vstest#15629) - Fix SCI binding failure in DTA hosts (rel/18.6) by [@​nohwnd](https://github.com/nohwnd) in [#​15722](microsoft/vstest#15722) - Remove DiagnosticSource binding redirect (rel/18.6) by [@​nohwnd](https://github.com/nohwnd) in [#​15776](microsoft/vstest#15776) **Full Changelog**: <microsoft/vstest@v18.5.1...v18.6.0> </details> --- ### Configuration 📅 **Schedule**: (in timezone Europe/Lisbon) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNjguNiIsInVwZGF0ZWRJblZlciI6IjQzLjE2OC42IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbInJlbm92YXRlYm90Il19--> Reviewed-on: https://devops-01.marinha.pt/marinha-si/pessoas-integracao/pulls/603 Reviewed-by: João Raimundo <pacheco.raimundo@marinha.pt> Co-authored-by: Renovate Bot <renovate-bot@marinha.pt> Co-committed-by: Renovate Bot <renovate-bot@marinha.pt>
When running multi-TFM tests, TRX files were overwritten because the default filename did not include the target framework. The TFM was already appended when using the
LogFilePrefixparameter, but not for the default auto-generated filename.This change appends the framework short name (e.g.
net10.0) to the default TRX filename, matching the existing behavior forLogFilePrefix.Before:
username_MACHINE_2026-03-24_07_51_08.trxAfter:
username_MACHINE_2026-03-24_07_51_08_net10.0.trxCloses #15506