Skip to content

Add --show-slowest-tests option to the core terminal reporter - #9894

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/jubilant-doodle
Jul 13, 2026
Merged

Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/jubilant-doodle

Conversation

@Evangelink

@Evangelink Amaury Levé (Evangelink) commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

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.

  • Off by default (absent = disabled), so existing summary output is byte-identical and no acceptance snapshots churn.
  • Ranks by the reported per-test execution duration (TimingProperty.GlobalTiming.Duration). Note: this is the producer-reported total, which for MSTest includes TestInitialize/TestCleanup — it is not a method-only measurement.
  • Works for 1 and N assemblies at the reporter level: a flat list for the in-process host / single assembly, and a per-assembly list when more than one assembly is registered (each assembly shows its own top-N — no cross-assembly merge).
  • All outcomes included (a slow test that then fails is still slow).
  • Retry-safe: recording happens on every completion, keyed by test node uid, so a retry replaces (or, when it reports no timing, clears) the earlier attempt's duration rather than duplicating or leaving stale data.
  • Deterministic (ties broken by display name) for stable snapshots.
  • Recording is gated on the feature, so a normal run pays no bookkeeping cost.

Scope note on dotnet test

The change lives in the shared core terminal reporter. Wiring --show-slowest-tests through the dotnet test CLI (so it sets SlowestTestsCount on the orchestrator reporter) is owned by the dotnet/sdk CLI — TerminalReporterContract.props deliberately 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) and GetSlowestTests(count).
  • TerminalTestReporterOptions.SlowestTestsCount (0 = off) + TerminalTestReporter.Summary rendering.
  • TerminalTestReporterCommandLineOptionsProvider: new --show-slowest-tests option + positive-integer validation; wired in TerminalOutputDevice.Initialization.
  • Resources: TerminalResources (.resx + accessor) with xlf regenerated via UpdateXlf (all 13 languages).
  • InternalAPI.Unshipped.txt entries for the new internal members.
  • Help/info acceptance expectations updated (MTP HelpInfoTests, HelpInfoAllExtensionsTests, MSTest HelpInfoTests).
  • Unit tests: rendering (flat + per-assembly), off-by-default, retry replacement (same uid, and untimed retry), and full CLI validation coverage.

Verification

  • Builds clean across net8.0/net9.0/netstandard2.0/net462; the dotnet/sdk-vendored reporter contract project still builds (shared source intact).
  • 1325 unit tests pass.
  • End-to-end: --show-slowest-tests 5 renders the ranked section; abc/0 are rejected with the localized message.
  • Live --help/--info output matches the updated expectations.

Note: the full acceptance help/info suite (which requires -pack) was not run locally; live --help/--info output was verified against the updated expectation strings instead.

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
Copilot AI review requested due to automatic review settings July 13, 2026 10:42

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.

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

@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review July 13, 2026 11:42
Copilot AI review requested due to automatic review settings July 13, 2026 11:42
- 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

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.

Review details

  • Files reviewed: 26/26 changed files
  • Comments generated: 4
  • Review effort level: Medium

Copilot AI review requested due to automatic review settings July 13, 2026 11:51

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.

Review details

  • Files reviewed: 26/26 changed files
  • Comments generated: 2
  • Review effort level: Medium

- 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
Copilot AI review requested due to automatic review settings July 13, 2026 12:01

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.

Review details

  • Files reviewed: 27/27 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

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
Copilot AI review requested due to automatic review settings July 13, 2026 12:07

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.

Review details

  • Files reviewed: 27/27 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #9894

GradeTestNotes
A (90–100) new TerminalTestReporterCommandLineOptionsProviderTests.
GetSlowestTestsCount_
WhenOptionSetToPositiveInteger_
ReturnsThatCount
Clear AAA; data-driven equality assertion correctly validates the --show-slowest-tests parse-to-reporter wiring across three representative values.
A (90–100) new TerminalTestReporterCommandLineOptionsProviderTests.
GetSlowestTestsCount_
WhenOptionAbsent_
ReturnsZero
Clean default-case test; equality assertion directly verifies the absent-option contract returns zero.

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Re-run with
/grade-tests.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · 39.2 AIC · ⌖ 5.92 AIC · ⊞ 8.9K · [◷]( · ◷)

@Evangelink
Amaury Levé (Evangelink) merged commit 31ec1d1 into main Jul 13, 2026
75 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/jubilant-doodle branch July 13, 2026 13:20
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.

2 participants