You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To de defined: should this be a core feature or an extension feature?
I think that because this is not linked to any external deps/service this could be a built-in feature but we could think about having it directly as some external package it we are planning to connect it to some service (AzDO?). Marco Rossignoli (@MarcoRossignoli) if I am not mistaken, nothing prevents us (technically) to have this feature as core (built-in) feature and to potentially have some extensions that would enrich this feature (e.g. connection to some history service), right?
I would personally do not add "questionable" service built-in. UX falls already in that bucket but we need to show something and we're giving our taste.
I would keep as an extension.
Slowest test is also a not well defined concept. Hypothetical fixture system, init feature etc...are affecting the concept of slowest? If my custom adapter group by "group of tests with a category" and I want to measure that group? Some other esoteric framework could implement different concept regarding timing, personally I would not add in the core lib but in an extension where we ship "our" idea of slowest.
When implementing this, we should also consider how we want dotnet test to behave.
Should dotnet test re-implement this feature in a way that considers all test projects and show the slowest test for the whole test session? Or should this be a per-testapp feature.
This question generally keeps popping up for various features.
Adding a thought from a recent design discussion (#9125, #9139, #9140) — a related angle worth capturing on this issue.
A different framing: declared expected duration
Instead of "platform calculates which tests are slowest" (relative, list-based — the original framing of this issue), what if:
Each test declares its expected duration (or expected range); the platform surfaces a warning when actual > declared.
That's a declarative twin of #9140's history-driven threshold — same emission point, different input source. Author knows this integration test should complete in under 2s; CI, IDE, and reporters all surface a warning when it doesn't.
Three architectural options
Approach
Cost
Trade-off
a
Pure extension. Each framework ships its own attribute (e.g. [ExpectedDuration(2000)] on MSTest, equivalent on xUnit/NUnit). An extension reads it, compares, warns via the IProgressEnricher hook (#9139).
Zero MTP changes.
N frameworks → N attribute conventions → N extensions. Reporters can't act uniformly without per-framework knowledge.
b
Platform contract. MTP defines a standard test-node metadata key (expected.duration.max etc.); framework bridges populate it from whatever attribute the framework chooses; platform emits a SlowExpectedTest event when exceeded.
Public API addition + buy-in from adapter authors.
One standard surface; reporters and extensions act uniformly.
c
Hybrid. Platform exposes the metadata key + warning event; frameworks may populate it; UI/log emission is delegated to extensions/reporters.
Modest.
Probably the right balance with Marco's earlier don't put taste in core guidance on this very issue.
The "what state?" question — recommend not introducing a new TestOutcome
A slow-but-correct test passed its assertions. Marking it failed:
Breaks the meaning of fail — green/red CI signal becomes ambiguous (people chase non-bugs).
Maps awkwardly into TRX/JUnit XML — no PassedWithWarning state exists in those formats; they'd round to pass anyway.
Conflicts mentally with the hard-timeout semantics frameworks already have ([Fact(Timeout = 1000)], MSTest [Timeout], NUnit [Timeout] all FAIL the test when exceeded).
Recommended principle: outcome stays Passed; the warning rides on a separate annotation channel on the result. Reporters render yellow/orange; CI extensions emit ::warning:: (GitHub) or ##vso[task.logissue type=warning] (AzDO); IDEs can surface a slow tests filter. Test still counts as passing in counts and exit codes.
If a user genuinely wants hard failure on slow tests, the existing Timeout attributes already do that.
Coexistence with existing Timeout
Two distinct concepts that can coexist on the same test:
Enables uniform IDE integration (Test Explorer can show slow tests across frameworks).
If we choose (a), it's purely a framework-by-framework story and MTP should stay out of it (which is consistent with Marco Rossignoli (@MarcoRossignoli)'s earlier comment on this issue).
Open questions
(a), (b), or (c)? Leaning (c) personally — keeps core lean while making the data uniform.
Single max only, or full min/target/max range? Range adds unexpectedly fast detection (regression-the-other-way), but more API surface.
Per data row or per method for parameterised tests?
Related design context: #9125 (umbrella for progress reporting), #9139 (IProgressEnricher hook surface this would plug into), #9140 (history-driven threshold — the dynamic twin of this declarative proposal).
Bringing an energy-efficiency lens to this design discussion.
Why "slowest tests" matters for energy
From a Green Software Foundation perspective, every second of unnecessary test-host CPU time translates to joules consumed — across CI machines, developer laptops, and cloud runners. A test that takes 30 s when it should take 3 s burns roughly 10× the energy for that one invocation. Multiply by a typical CI frequency (dozens of runs per day per repo) and the cumulative waste becomes significant.
The declarative expected duration approach outlined above (option c) maps naturally onto this:
It makes energy cost visible — a slow test that regularly exceeds its declared budget shows up in dashboards, giving maintainers actionable data to investigate.
It creates a feedback loop without blocking CI — the test still passes, but the warning surfaces the inefficiency without creating noise.
Energy-efficient implementation considerations
If a SlowExpectedTest warning path is added, a couple of implementation notes from an efficiency angle:
Avoid per-test allocations in the happy path. The comparison actual > declared should be a simple arithmetic compare on pre-stored integers. If the threshold comes from a custom attribute, cache it at discovery time alongside TestMethodInfo/TestNodeDescriptor rather than re-reading it per invocation.
Emit the warning lazily. If zero tests exceed their threshold (the common case), the warning-construction and routing code should never execute — guard with an early if (elapsed > threshold) before any allocation.
Reporting vs. per-test overhead. The existing SlowTests tracking in the terminal reporter (SimplifiedConsoleOutputDeviceBase.SlowTests.cs) already batches display — the same pattern works here.
Connecting to SCI
The [Software Carbon Intensity (SCI)]((sci.greensoftware.foundation/redacted) equation SCI = (E × I + M) / R applies directly to test suites: the functional unit R is "one CI run". Identifying and fixing chronically slow tests reduces E (energy consumed per run), lowering SCI. A platform-level mechanism that surfaces slow tests gives teams the data they need to act.
Option (c) (platform metadata key + extension rendering) seems like the right call for this reason too — it keeps the measurement instrumentation in one place, making it easy to aggregate SCI-relevant data across frameworks.
🤖 Automated content by GitHub Copilot. Generated by the Efficiency Improver workflow. · sonnet46 117 AIC · ⌖ 4.19 AIC · ⊞ 14.2K · [◷]( · ◷)
Add this agentic workflow to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/efficiency-improver.md@main
The original per-assembly request is delivered by #9894: --show-slowest-tests <count> lists the slowest completed tests in the run summary. Closing that original scope as completed. The separate opt-in MSTest soft-duration-budget proposal is tracked in #12245; that work preserves existing test outcomes and timeout behavior.
Activity
Evangelink commentedon Aug 8, 2024
To de defined: should this be a core feature or an extension feature?
I think that because this is not linked to any external deps/service this could be a built-in feature but we could think about having it directly as some external package it we are planning to connect it to some service (AzDO?).
Marco Rossignoli (@MarcoRossignoli) if I am not mistaken, nothing prevents us (technically) to have this feature as core (built-in) feature and to potentially have some extensions that would enrich this feature (e.g. connection to some history service), right?
MarcoRossignoli commentedon Aug 8, 2024
I would personally do not add "questionable" service built-in. UX falls already in that bucket but we need to show something and we're giving our taste.
I would keep as an extension.
Slowest test is also a not well defined concept. Hypothetical fixture system, init feature etc...are affecting the concept of slowest? If my custom adapter group by "group of tests with a category" and I want to measure that group? Some other esoteric framework could implement different concept regarding timing, personally I would not add in the core lib but in an extension where we ship "our" idea of slowest.
Youssef1313 commentedon Jan 20, 2026
When implementing this, we should also consider how we want
dotnet testto behave.Should
dotnet testre-implement this feature in a way that considers all test projects and show the slowest test for the whole test session? Or should this be a per-testapp feature.This question generally keeps popping up for various features.
Evangelink commentedon Jun 15, 2026
Adding a thought from a recent design discussion (#9125, #9139, #9140) — a related angle worth capturing on this issue.
A different framing:
declared expected durationInstead of "platform calculates which tests are slowest" (relative, list-based — the original framing of this issue), what if:
That's a declarative twin of #9140's history-driven threshold — same emission point, different input source. Author knows
this integration test should complete in under 2s; CI, IDE, and reporters all surface a warning when it doesn't.Three architectural options
[ExpectedDuration(2000)]on MSTest, equivalent on xUnit/NUnit). An extension reads it, compares, warns via theIProgressEnricherhook (#9139).expected.duration.maxetc.); framework bridges populate it from whatever attribute the framework chooses; platform emits aSlowExpectedTestevent when exceeded.don't put taste in coreguidance on this very issue.The "what state?" question — recommend not introducing a new
TestOutcomeA slow-but-correct test passed its assertions. Marking it failed:
fail— green/red CI signal becomes ambiguous (people chase non-bugs).PassedWithWarningstate exists in those formats; they'd round topassanyway.[Fact(Timeout = 1000)], MSTest[Timeout], NUnit[Timeout]all FAIL the test when exceeded).Recommended principle: outcome stays
Passed; the warning rides on a separate annotation channel on the result. Reporters render yellow/orange; CI extensions emit::warning::(GitHub) or##vso[task.logissue type=warning](AzDO); IDEs can surface aslow testsfilter. Test still counts as passing in counts and exit codes.If a user genuinely wants hard failure on slow tests, the existing
Timeoutattributes already do that.Coexistence with existing
TimeoutTwo distinct concepts that can coexist on the same test:
[Fact(Timeout)], MSTest[Timeout], NUnit[Timeout]Example intent:
[ExpectedDuration(2_000)] [Timeout(10_000)]→ "I expect this in ≤2s, kill it at 10s."Is there a point at all in having this on MTP side?The blunt answer: only if we choose (b) or (c).
IProgressEnrichersurface from Silence-driven progress heartbeat renderer for SimpleAnsi/NoAnsi terminal modes #9139.slow testsacross frameworks).If we choose (a), it's purely a framework-by-framework story and MTP should stay out of it (which is consistent with Marco Rossignoli (@MarcoRossignoli)'s earlier comment on this issue).
Open questions
maxonly, or fullmin/target/maxrange? Range addsunexpectedly fastdetection (regression-the-other-way), but more API surface.2s) and relative (3× historical p99, from Azure DevOps history-driven slow-test threshold enricher #9140) declarations, so reporters have one thing to render?Related design context: #9125 (umbrella for progress reporting), #9139 (
IProgressEnricherhook surface this would plug into), #9140 (history-driven threshold — the dynamic twin of this declarative proposal).github-actions commentedon Jul 30, 2026
Bringing an energy-efficiency lens to this design discussion.
Why "slowest tests" matters for energy
From a Green Software Foundation perspective, every second of unnecessary test-host CPU time translates to joules consumed — across CI machines, developer laptops, and cloud runners. A test that takes 30 s when it should take 3 s burns roughly 10× the energy for that one invocation. Multiply by a typical CI frequency (dozens of runs per day per repo) and the cumulative waste becomes significant.
The declarative
expected durationapproach outlined above (option c) maps naturally onto this:Energy-efficient implementation considerations
If a
SlowExpectedTestwarning path is added, a couple of implementation notes from an efficiency angle:Avoid per-test allocations in the happy path. The comparison
actual > declaredshould be a simple arithmetic compare on pre-stored integers. If the threshold comes from a custom attribute, cache it at discovery time alongsideTestMethodInfo/TestNodeDescriptorrather than re-reading it per invocation.Emit the warning lazily. If zero tests exceed their threshold (the common case), the warning-construction and routing code should never execute — guard with an early
if (elapsed > threshold)before any allocation.Reporting vs. per-test overhead. The existing
SlowTeststracking in the terminal reporter (SimplifiedConsoleOutputDeviceBase.SlowTests.cs) already batches display — the same pattern works here.Connecting to SCI
The [Software Carbon Intensity (SCI)]((sci.greensoftware.foundation/redacted) equation
SCI = (E × I + M) / Rapplies directly to test suites: the functional unitRis "one CI run". Identifying and fixing chronically slow tests reducesE(energy consumed per run), lowering SCI. A platform-level mechanism that surfaces slow tests gives teams the data they need to act.Option (c) (platform metadata key + extension rendering) seems like the right call for this reason too — it keeps the measurement instrumentation in one place, making it easy to aggregate SCI-relevant data across frameworks.
Add this agentic workflow to your repo
To install this agentic workflow, run
Evangelink commentedon Nov 6, 2026
The original per-assembly request is delivered by #9894:
--show-slowest-tests <count>lists the slowest completed tests in the run summary. Closing that original scope as completed. The separate opt-in MSTest soft-duration-budget proposal is tracked in #12245; that work preserves existing test outcomes and timeout behavior.