Repository navigation
Description
Summary
Add an optional, per-test soft duration budget to MSTest. A test that exceeds its declared budget should finish normally and produce a warning without changing its original outcome, result counts, exit code, or timeout behavior.
This is the distinct remaining proposal from #3495. The original per-assembly slowest-test list is already delivered by #9894 through --show-slowest-tests <count>.
Background and Motivation
Ranking the slowest tests and reporting tests that are still running answer different questions from checking an author's intended upper bound. An explicit budget works locally, on the first run, and without CI credentials or historical services. It can identify a normally short test that regresses without entering a top-N slowest list.
Budgets are diagnostic expectations, not controlled performance benchmarks: machine speed, contention, debugging, and cold starts can affect durations. Existing [Timeout] remains the separate execution-failure/cancellation mechanism.
Proposed Feature
- Introduce an opt-in MSTest attribute, provisionally
[ExpectedDuration(milliseconds)], declaring one positive upper bound on a test method. - Evaluate the completed execution using the existing MSTest result-duration boundary; document initialization/cleanup, data-row, retry, and custom test-method behavior.
- Emit a warning identifying the test, actual duration, and expected maximum when the budget is exceeded. Preserve the test's original pass/fail/skip outcome and all existing timeout and cancellation behavior.
- Use existing MSTest adapter and host warning/reporting mechanisms for MTP and VSTest. Do not introduce a new MTP test outcome or assume an
IProgressEnrichercontract exists. - Keep unannotated tests unchanged. Cover reflection and source-generated execution where supported, using focused tests and real packed-package consumers.
Non-goals: minimum/target/maximum ranges, hard performance gates, new history services, solution-wide ranking, or a general platform extension-hook API.
Alternative Designs
- Existing slowest-test lists: useful for ranking, but do not express a test-specific expectation.
- Existing live notices and Azure DevOps history thresholds (Azure DevOps history-driven slow-test threshold enricher #9140): useful for active tests, but history is service-dependent and does not encode an intentional budget.
[Timeout]: deliberately changes execution/failure behavior rather than issuing a non-blocking diagnostic.- Configuration-only or custom-extension budgets: avoid new public attributes, but separate expectations from the test and require additional matching/configuration conventions.
- Standardized MTP metadata and cross-framework rendering: defer until concrete consumers justify that additional platform API and transport contract.
The implementation decision record will retain the final timing contract, alternatives, consumer coverage, and revision-bound behavioral evidence.
Activity