Repository navigation
Add experimental MSTest executable test resources and TRX collection - #21559
Conversation
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
5fc0e2b to
7f8e699
Compare
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21559Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21559" |
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
7f8e699 to
83602b3
Compare
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
83602b3 to
bb26ba9
Compare
This comment has been minimized.
This comment has been minimized.
bb26ba9 to
2ab2ab8
Compare
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
2ab2ab8 to
0e21423
Compare
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
0e21423 to
7922de9
Compare
Configure fresh runner report directories before startup, stage finalized artifacts into the runtime resource output, and retain cleanup through the AppHost file-system service. Co-authored-by: Copilot App <[email protected]>
Map explicit TRX error, timeout, inconclusive and aborted results without inferring categories lost by MTP serialization. Reconcile category counters and preserve independent run-level failures. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
cdfe8f5 to
8457d04
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Argument validation misses supported single-dash and colon-delimited option spellings, allowing explicitly unsupported behavior such as server mode that can prevent normal completion and TRX collection.
1 open issue
What changed in this PR
Adds experimental MSTest support to Aspire.Hosting.Dotnet, building on the resource-bound aspire test foundation. Executable MSTest projects can use normal Aspire references and waits, with TRX results collected into the shared test summary.
Changes:
- Introduces
AddMsTest,MsTestResource, andMsTestOptions, with TypeScript exports. - Adds TRX parsing, outcome validation, artifact staging, and launch-time reporting configuration.
- Adds focused tests, snapshots, documentation, and a shared-service playground fixture.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Dotnet.Tests/Snapshots/MsTestTrxReportTests.NormalizesDataRowsOutcomesDurationsAndEscapedDiagnostics.verified.txt | Records normalized results and diagnostics. |
| tests/Aspire.Hosting.Dotnet.Tests/MsTestTrxReportTests.cs | Tests TRX parsing, outcomes, counters, and invalid reports. |
| tests/Aspire.Hosting.Dotnet.Tests/MsTestResourceTests.cs | Tests resource configuration and lifecycle restrictions. |
| tests/Aspire.Hosting.Dotnet.Tests/MsTestCollectorTests.cs | Tests collection, artifact safety, and real runner execution. |
| tests/Aspire.Hosting.Dotnet.Tests/Helpers/MsTestReportFixture.cs | Provides reusable TRX fixtures. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/MsTestExportTests.GeneratesOneAddMsTestMethodWithTypedOptionsAndExecutableCapabilities.verified.txt | Records generated TypeScript contracts. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/MsTestExportTests.cs | Verifies MSTest TypeScript exports. |
| src/Aspire.Hosting.Dotnet/README.md | Documents MSTest setup, collection, and limitations. |
| src/Aspire.Hosting.Dotnet/MsTestTrxReport.cs | Parses TRX reports and stages artifacts. |
| src/Aspire.Hosting.Dotnet/MsTestResource.cs | Defines the experimental executable resource. |
| src/Aspire.Hosting.Dotnet/MsTestOptions.cs | Defines build-selection and runner options. |
| src/Aspire.Hosting.Dotnet/MsTestHostingExtensions.cs | Registers MSTest resources and configures reporting. |
| src/Aspire.Hosting.Dotnet/Aspire.Hosting.Dotnet.csproj | Enables integration analyzers. |
| playground/AspireCliTesting/README.md | Documents combined scenarios and invocation-scoped opt-in. |
| playground/AspireCliTesting/mstest-tests/ServiceTests.cs | Exercises service access, failure, and skipped results. |
| playground/AspireCliTesting/mstest-tests/Playground.MSTest.csproj | Configures the executable MSTest fixture and TRX extension. |
| playground/AspireCliTesting/mstest-tests/Directory.Build.targets | Isolates the fixture from repository runner targets. |
| playground/AspireCliTesting/mstest-tests/Directory.Build.props | Isolates the fixture from repository build properties. |
| playground/AspireCliTesting/apphost.cs | Connects the MSTest fixture to the shared service. |
Review effort: Balanced
Co-authored-by: Copilot App <[email protected]>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <[email protected]>
Tests selector21 / 101 PR test projects · 4 PR jobs, from 17 changed files. Selected PR test projects (21 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🔧 show 17
🔧 🔧 🔧 🔧 📦 affected project 📄 📄 📄 📄 📄 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
88c7bca539e15ae8d2fd9c2e2903b65919ab7603↑ Parent8457d04 passed79 MSTest tests, including real MTP success/failure, two export tests and AppHost build; no executable code changed since.
↓ Restart, temporary cleanup and deferred arguments remain explicitly accepted nonblocking follow-ups in #22706, #22707 and #22708; a separate parser-option review finding remains unaddressed.
↓ Final-head CI/native validation is pending or running; cross-platform/full CLI behavior was not rerun locally.
Description
Adds the experimental MSTest layer of the Aspire testing stack:
AddMsTest,MsTestResource : ExecutableResource, andMsTestOptionsinAspire.Hosting.Dotnet. An executable MSTest project composes normal references, environment variables and waits, and publishes individual TRX results duringaspire test. All new hosting testing APIs are experimental underASPIRETESTING001, with TypeScript export coverage.Foundation #21527 is merged into main at
16f52aeb827e6415fa1e1d318a98dcdad607bcc5. This PR now targetsmainat that exact revision. Current MSTest head:88c7bca539e15ae8d2fd9c2e2903b65919ab7603onmitchdenny-mstest-testing-integration.Nov26 documentation follow-ups remove “shared by its replicas” from the MSTest artifact-directory paragraph, addressing José's review, and clarify James's failed-summary finding: a failed TRX run summary causes a collection error only when no individual failing outcome explains it; with failing cases, collection can complete successfully while the overall test outcome fails. Both are precise README-only corrections; no production code, generated API or lifecycle behavior changed. The commits were pushed with explicit observed-tip leases against
8457d04b28670374abc750f30749dff74bcb2fc6and382b7f1d3f95c7893eb2aae0c93e936c84ed7177, respectively. José's and James's documentation threads are resolved after their respective fixes were pushed.Three runtime findings are explicitly nonblocking follow-ups, not fixes in this PR: Restart ordering #22706, temporary-report cleanup #22707, and deferred runner arguments #22708. Each issue links its original James discussion, and each discussion links its issue; those three threads are resolved with the deferral stated explicitly. A separate parser-option syntax review finding remains unaddressed by these documentation/follow-up changes.
Nov26 reconciliation: GitHub had already retargeted and rebased this PR after the foundation merge. The verified server head
8457d04b28670374abc750f30749dff74bcb2fc6contains current main and exactly the eight intended MSTest patches;git range-diffconfirms each patch is identical to the previous headcdfe8f543daf1d52b5d51930ce6f7e38ceea73ea. The owning worktree adopted that verified server head; no additional rebase was necessary. Existing non-draft state and native stack #22374 complete membership [#21527, #21559, #21580, #21585, #21587, #21675], including merged foundation, were preserved. No unstack/recreate, upper propagation, metadata changes, merge or auto-merge. Dashboard #21646 remains closed/removed.Fixes: N/A (feature request; foundation #21527 is merged).
Usage
The preview CLI command is disabled by default. Opt in per invocation without changing global configuration:
features__testCommandEnabled=true aspire testThe project must enable the MTP executable runner and register
Microsoft.Testing.Extensions.TrxReport; MSTest.Sdk's Default profile supplies both. Aspire does not change project dependencies or runner configuration. Optional configuration, selected target framework and structured runner argument tokens are supported. Invocation usesdotnet run --project <absolute.csproj> --no-launch-profile -- .... Ordinary runs omit Aspire reporting flags and collection; publish excludes the resource. This initial executable-based integration builds independently of the AddDotnetProject coordinator; shared build outputs can contend.Collection and artifacts
Uses the foundation's runtime-only
WithTesting(Func<ResourceTestingContext, Task>?)callback. Repeated calls replace the callback; marker-only clears collection while retaining context. Runner setup is independent of that replaceable callback. Remote callback timeout, connection lifetime, cancellation and invocation-gate release/reentry behavior come from the foundation.During test-mode
OnBeforeStart, the integration resolves AppHostIFileSystemServiceand allocates a fresh tracked temporary report directory, then appends reserved MTP reporting arguments. Collection waits for resource completion before resolving the launch-owned report path and stages finalized artifacts even after a nonzero exit. The filesystem service owns temporary cleanup, including failed startup/disposal, subject to its debugging preservation option.context.TestingContext.OutputPathis the run root;context.OutputPathis the flat logical-resource directory. Only this invocation's canonicalresults.trxis read. Staging rejects source/destination links and reparse points, refuses overwrites, and does not traverse TRX attachment references. Missing/malformed reports and collector errors fail explicitly; malformed raw artifacts remain staged. Cancellation interrupts waits and copying. The cumulativeplayground/AspireCliTestingfixture preserves the foundation service/probe/cleanup and source-dashboard wiring.Outcomes and reporting
Explicit TRX mappings: Passed → Passed, Failed → Failed, NotExecuted → Skipped, Inconclusive → Inconclusive, Error → Error, Timeout → TimedOut, Aborted → Cancelled. Only Passed and Skipped are non-failing. Published TimedOut/Cancelled cases cause ordinary CLI test failure23, not command timeout17 or interruption130. Unknown/progress-only states are parser errors. Counter reconciliation and strict identities prevent double-counting. A failed TRX run summary causes a collection error when no individual failing outcome explains it, without fabricating cases or rewriting real Passed/Skipped results; with failing cases, collection can complete successfully while the overall test outcome fails.
Current MTP serializes timeout rows as Failed, retaining timeout only in aggregate counters, and collapses error/cancellation into Failed. Those rows remain Failed: this integration does not infer identities or recover categories lost upstream from messages/counters. Sources: TRX serializer, MTP state converter, TRX outcomes.
The inherited unreleased CLI contract is schemaVersion1: resource-keyed
testResultscontains independent execution, collector and case observations;testSummarycontains the overall outcome and actual passed/failed/skipped counts. Partial cases survive collection failure; resource-only observations do not fabricate case counts. Multi-replica observations are keyed by actual resource ID. Backchannel v1 is unchanged. The playground artifact lookup istestResults[resourceName].outputPath; previously declined feature-opt-in README prose was not reintroduced. The inherited spec/timeout helpers remain unchanged, including proposed-only AddCargoTest.Validation and readiness
Nov26 validated parent
8457d04b28670374abc750f30749dff74bcb2fc6, macOS arm64 with the repository SDK: 81 focused tests and cumulative AppHost build passed. Final head differs only by José's replica wording and James's failed-summary README corrections; executable tests were not repeated solely for those documentation edits. Wording was checked against the exactreport.Failed && report.Results.All(result => result.Outcome is TestOutcome.Passed or TestOutcome.Skipped)collection condition; whitespace checks passed.dotnet test --project tests/Aspire.Hosting.Dotnet.Tests/Aspire.Hosting.Dotnet.Tests.csproj --no-launch-profile -- --filter-class '*.MsTest*' --filter-not-trait 'quarantined=true'— passed79, including two explicitly targeted real isolated MTP pass/fail runners, parser/outcome/counter handling, staging/link rejection, cancellation, cleanup, callback replacement and ordinary run/publish behavior.dotnet test --project tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj --no-launch-profile -- --filter-method '*.GeneratesOneAddMsTestMethodWithTypedOptionsAndExecutableCapabilities' --filter-method '*.Scanner_WithTesting_ExportsSingleOptionalRuntimeCollector' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed2; generated API/context/callback exports unchanged.dotnet build playground/AspireCliTesting/apphost.cs --verbosity quiet— passed.Range-diff confirms all eight original patches unchanged; current main ancestry, whitespace and clean worktree verified. No RunCommand or RunCommandStrings diff against current main.
GitHub currently reports MERGEABLE/conflict-free, APPROVED, and BLOCKED while checks run. The existing approval was submitted on the earlier patch-identical head and remains retained by GitHub. Final-head CI45747652984 is pending, native45747652413 and automated review are running; no current-head green CI claim is made. The earlier parent CI45743335067 and native45743334822 are historical links, not final-head results. No unconditional merge-ready claim is made. The foundation is merged, no longer an open stack prerequisite.
Previous Nov25 head
cdfe8f543daf1d52b5d51930ce6f7e38ceea73ea, before the foundation squash merge/server rebase, passed132 focused tests and the AppHost build. In addition to the same79 MSTest/two export tests above,dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.TestRunReporterTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'passed51, including schemaVersion1 resource-keyed reporting, replicas, retained partial cases and independent execution/collection/case outcomes. These51 reporter tests were not rerun in the Nov26 reconciliation; MSTest executable code is unchanged.Historical evidence, not rerun whole-CLI coverage on this head: Nov23 parent
baf66756d9846c6bc7fb16179ef77c9d00940c20passed211 focused tests plus AppHost build, and actual isolated source-CLI pass/fail invocations verified four passed/zero failed/one skipped (exit0), and three passed/one failed/one skipped (exit23, MSTest exit2), completed collection, staged TRX/probe artifacts and persisted-summary equality. Those historical JSON runs used the transient schemaVersion2 before correction to1; no compatibility promise is implied. No full CLI runtime, other guest SDK suite, user AppHost/browser/terminal operation or global config change was performed for this reconciliation.Security assumptions
Runs trusted local test code, not sandboxed workloads. Structured arguments avoid shell concatenation; reporting redirection, response files, server mode and retry options are reserved. XML disables DTD/external resolution, bounds size and validates identities/counters. Staging rejects links/reparse points, does not traverse attachment references and never overwrites files. Foundation/CLI owns private runtime directories; runner files and staged copies use their writer's permissions, not a per-file0600 guarantee. Process/artifact handling still needs review.
Checklist
<remarks />and<code />elements on your triple slash comments?