Repository navigation
Add --show-slowest-tests option to the core terminal reporter - #9894
Merged
Merged
Conversation
Adds an opt-in built-in option --show-slowest-tests <N> that appends a 'Slowest tests' section to the run summary, ranking tests by their reported execution duration (fixture time excluded). Renders a flat list for the in-process host and a per-assembly list under the dotnet test orchestrator. Off by default. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b550389a-3aa0-4911-8bda-c1da41218b5a
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in core terminal summary listing the slowest tests by reported duration.
Changes:
- Records and ranks per-test durations, including per-assembly output.
- Adds and validates
--show-slowest-tests <N>. - Updates resources, API tracking, help expectations, and tests.
Show a summary per file
| File | Description |
|---|---|
test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs |
Tests summary rendering. |
test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs |
Updates MSTest help expectation. |
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs |
Updates MTP help/info expectations. |
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.cs |
Updates all-extensions expectations. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.Initialization.cs |
Wires CLI count into reporter options. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestProgressState.cs |
Stores and ranks test durations. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterOptions.cs |
Adds the slowest-test count option. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs |
Defines and validates the CLI option. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.TestCompletion.cs |
Records completed-test durations. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.Summary.cs |
Renders slowest-test summaries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalResources.resx |
Adds user-facing strings. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalResources.cs |
Adds resource accessors. |
src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt |
Tracks new internal APIs. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.cs.xlf |
Adds Czech localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.de.xlf |
Adds German localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.es.xlf |
Adds Spanish localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.fr.xlf |
Adds French localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.it.xlf |
Adds Italian localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.ja.xlf |
Adds Japanese localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.ko.xlf |
Adds Korean localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.pl.xlf |
Adds Polish localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.pt-BR.xlf |
Adds Portuguese localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.ru.xlf |
Adds Russian localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.tr.xlf |
Adds Turkish localization entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.zh-Hans.xlf |
Adds Simplified Chinese entries. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/xlf/TerminalResources.zh-Hant.xlf |
Adds Traditional Chinese entries. |
Review details
- Files reviewed: 26/26 changed files
- Comments generated: 3
- Review effort level: Medium
- GlobalTiming.Duration includes TestInitialize/TestCleanup, so the 'excluding fixture time' promise was inaccurate; reword help/docs to 'by reported execution duration'. - Record duration on every completion and remove the uid when the latest attempt reports no timing, so an untimed retry no longer leaves a stale first-attempt duration ranked. Add a retry regression test. - Clarify the multi-assembly test/comment: it exercises the reporter's rendering path; wiring --show-slowest-tests through dotnet test is owned by the dotnet/sdk CLI. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b550389a-3aa0-4911-8bda-c1da41218b5a
- Multi-assembly test: make a-fast (7s) globally slower than b-slow (6s) so the assertions distinguish per-assembly top-1 from a merged global ranking. - Add same-uid retry test verifying only the latest attempt's duration is ranked (stale first-attempt duration is dropped). - Add --show-slowest-tests CLI validation unit tests (positive, zero, negative, nonnumeric, fractional, empty, multiple args, option metadata). Co-authored-by: Copilot App <[email protected]> Copilot-Session: b550389a-3aa0-4911-8bda-c1da41218b5a
Expose TerminalOutputDevice.GetSlowestTestsCount (internal) and unit-test that a parsed --show-slowest-tests value reaches the reporter option, so a validation/initialization regression can't leave a help-only option. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b550389a-3aa0-4911-8bda-c1da41218b5a
Contributor
🧪 Test quality grade — PR #9894
This advisory comment was generated automatically. Grades are heuristic Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
This was referenced Nov 6, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a core (built-in) "slowest tests" report for Microsoft.Testing.Platform, addressing part of #3495.
Adds an opt-in built-in option
--show-slowest-tests <N>that appends a Slowest tests section to the run summary, ranking tests by their reported execution duration.TimingProperty.GlobalTiming.Duration). Note: this is the producer-reported total, which for MSTest includesTestInitialize/TestCleanup— it is not a method-only measurement.Scope note on
dotnet testThe change lives in the shared core terminal reporter. Wiring
--show-slowest-teststhrough thedotnet testCLI (so it setsSlowestTestsCounton the orchestrator reporter) is owned by the dotnet/sdk CLI —TerminalReporterContract.propsdeliberately excludes the MTP options provider — and is a separate follow-up. The per-assembly rendering path is implemented and unit-tested here so the SDK can adopt it.Relationship to the AzDO/GitHub extensions
The Azure DevOps and GitHub Actions summary reporters already render their own per-assembly "Slowest tests" sections, and their live slow-test reporters surface tests still running past a threshold. Those are retrospective vs. live and remain unchanged. The gap was the core console summary, which had no slowest-tests section — this PR fills it. Being thresholdless and descriptive, it carries no opinion, which is what makes it appropriate for core.
Changes
TestProgressState: record per-test(displayName, duration)(nullable — clears on untimed retry) andGetSlowestTests(count).TerminalTestReporterOptions.SlowestTestsCount(0 = off) +TerminalTestReporter.Summaryrendering.TerminalTestReporterCommandLineOptionsProvider: new--show-slowest-testsoption + positive-integer validation; wired inTerminalOutputDevice.Initialization.TerminalResources(.resx + accessor) with xlf regenerated viaUpdateXlf(all 13 languages).InternalAPI.Unshipped.txtentries for the new internal members.HelpInfoTests,HelpInfoAllExtensionsTests, MSTestHelpInfoTests).Verification
--show-slowest-tests 5renders the ranked section;abc/0are rejected with the localized message.--help/--infooutput matches the updated expectations.