-
Notifications
You must be signed in to change notification settings - Fork 346
Speed up slowest acceptance tests and add --no-build consistently #15471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nohwnd
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
nohwnd:speed-up-slowest-acceptance-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| --- | ||
| name: trx-analysis | ||
| description: Parse and analyze Visual Studio TRX test result files. Use when asked about slow tests, test durations, test frequency, flaky tests, failure analysis, or test execution patterns from TRX files. | ||
| --- | ||
|
|
||
| # TRX Test Results Analysis | ||
|
|
||
| Parse `.trx` files (Visual Studio Test Results XML) to answer questions about test performance, frequency, failures, and patterns. | ||
|
|
||
| ## TRX File Format | ||
|
|
||
| TRX files use XML namespace `http://microsoft.com/schemas/VisualStudio/TeamTest/2010`. Key elements: | ||
|
|
||
| - `TestRun.Results.UnitTestResult` — individual test executions with `testName`, `duration` (HH:mm:ss.fffffff), `outcome` (Passed/Failed/NotExecuted) | ||
| - `TestRun.TestDefinitions.UnitTest` — test metadata including class and method info | ||
| - `TestRun.ResultSummary` — aggregate pass/fail/skip counts | ||
|
|
||
| ## Loading a TRX File | ||
|
|
||
| ```powershell | ||
| [xml]$trx = Get-Content "path/to/file.trx" | ||
| $results = $trx.TestRun.Results.UnitTestResult | ||
| ``` | ||
|
|
||
| ## Common Queries | ||
|
|
||
| ### Top N slowest tests | ||
|
|
||
| ```powershell | ||
| $results | ForEach-Object { | ||
| [PSCustomObject]@{ | ||
| Test = $_.testName | ||
| Seconds = [TimeSpan]::Parse($_.duration).TotalSeconds | ||
| Outcome = $_.outcome | ||
| } | ||
| } | Sort-Object Seconds -Descending | Select-Object -First 25 | | ||
| Format-Table @{L='Sec';E={'{0,6:N1}' -f $_.Seconds}}, Outcome, Test -AutoSize | ||
| ``` | ||
|
|
||
| ### Slowest test from each distinct class (top N) | ||
|
|
||
| ```powershell | ||
| $results | ForEach-Object { | ||
| $parts = $_.testName -split '\.' | ||
| [PSCustomObject]@{ | ||
| Test = $_.testName | ||
| ClassName = ($parts[0..($parts.Length-2)] -join '.') | ||
| Seconds = [TimeSpan]::Parse($_.duration).TotalSeconds | ||
| } | ||
| } | Sort-Object Seconds -Descending | | ||
| Group-Object ClassName | ForEach-Object { $_.Group | Select-Object -First 1 } | | ||
| Sort-Object Seconds -Descending | Select-Object -First 10 | | ||
| Format-Table @{L='Sec';E={'{0,6:N1}' -f $_.Seconds}}, ClassName, Test -AutoSize | ||
| ``` | ||
|
|
||
| ### Most-executed tests (parameterization frequency) | ||
|
|
||
| Extract the base method name before parameterization and count runs: | ||
|
|
||
| ```powershell | ||
| $results | ForEach-Object { | ||
| $name = $_.testName | ||
| if ($name -match '^(\S+?)[\s(]') { $base = $Matches[1] } else { $base = $name } | ||
| [PSCustomObject]@{ Base = $base; Seconds = [TimeSpan]::Parse($_.duration).TotalSeconds } | ||
| } | Group-Object Base | ForEach-Object { | ||
| [PSCustomObject]@{ | ||
| Runs = $_.Count | ||
| TotalSec = ($_.Group | Measure-Object Seconds -Sum).Sum | ||
| Test = $_.Name | ||
| } | ||
| } | Sort-Object TotalSec -Descending | Select-Object -First 20 | | ||
| Format-Table @{L='Runs';E={$_.Runs}}, @{L='TotalSec';E={'{0,7:N1}' -f $_.TotalSec}}, Test -AutoSize | ||
| ``` | ||
|
|
||
| ### Failed tests | ||
|
|
||
| ```powershell | ||
| $results | Where-Object { $_.outcome -eq 'Failed' } | ForEach-Object { | ||
| [PSCustomObject]@{ | ||
| Test = $_.testName | ||
| Seconds = [TimeSpan]::Parse($_.duration).TotalSeconds | ||
| Error = $_.Output.ErrorInfo.Message | ||
| } | ||
| } | Format-Table -Wrap | ||
| ``` | ||
|
|
||
| ### Summary statistics | ||
|
|
||
| ```powershell | ||
| $summary = $trx.TestRun.ResultSummary.Counters | ||
| [PSCustomObject]@{ | ||
| Total = $summary.total | ||
| Passed = $summary.passed | ||
| Failed = $summary.failed | ||
| Skipped = $summary.notExecuted | ||
| Duration = $trx.TestRun.Times.finish | ||
| } | Format-List | ||
| ``` | ||
|
|
||
| ## Tips | ||
|
|
||
| - Parameterized tests appear as separate `UnitTestResult` entries. Use regex `'^(\S+?)[\s(]'` to extract the base method name. | ||
| - Sort by **TotalSec** (runs × avg duration) to find tests that consume the most CI time overall, even if each individual run is fast. | ||
| - TRX files from CI are typically found in `TestResults/` or as pipeline artifacts. |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.