Skip to content

Add experimental Go test resources and raw output capture - #21585

Draft
Mitch Denny (mitchdenny) wants to merge 7 commits into
mitchdenny-pytest-testing-integrationfrom
mitchdenny-go-testing-integration
Draft

Mitch Denny (mitchdenny) wants to merge 7 commits into
mitchdenny-pytest-testing-integrationfrom
mitchdenny-go-testing-integration

Conversation

@mitchdenny

@mitchdenny Mitch Denny (mitchdenny) commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Description

Adds experimental AddGoTest/GoTestResource in Aspire.Hosting.Go on top of #21580. Ordinary execution uses go test; testing uses go test -json -count=1. References, waits, structured arguments, environment and telemetry compose normally. New public testing APIs use ASPIRETESTING001 and https://aka.ms/aspire/diagnostics/{0}.

#pragma warning disable ASPIRETESTING001
builder.AddGoTest("api-tests", "../go-api")
    .WithArgs("-tags=integration", "-run=TestAPI")
    .WithReference(api)
    .WaitFor(api);

Current propagation provenance

Head: 22319b0a22b153e4f4368cfd2225634010ff02aa. Base: mitchdenny-pytest-testing-integration at 3a48760a9298b6ac3574825ace06796e2c625afd, containing foundation 15048f5c78f081bbb534b0d81b842ab588966236 and pinned main 79127e0afa9cb87a5ba21abf5531441a33486a39.

Rebased only seven owning Go patches from verified boundary 4293aa2510cc8d82c88074b489a9082e5a32a278. Resolved the cumulative playground README conflict by retaining all Go capture/scenario content alongside the corrected testResults[resourceName].outputPath guidance. Compared with previous Go head 45a1c623bd6686a68ed0a1c56f110f2788ea62ea, Go runtime, parser, capture, deadline integration and AppHost sources are unchanged. No Cargo API changes or declined opt-in prose changes.

The resource-keyed CLI contract uses schemaVersion: 1, with testResults keyed by logical resource name and testSummary for the overall outcome and case counts. Resource entries retain cases, collector status/error, output path and execution/replica details; partial cases survive collector failure. notConfigured and null distinguish absent collectors from unobserved collection. There is no legacy format or migration path. Backchannel v1 is unchanged; Go execution tests consume those events and have no coupled CLI JSON reader.

Stack #22374 order remains foundation/MSTest/pytest/Go/Rust/Java, with unchanged bases/readiness/metadata and dashboard #21646 closed. RunCommand and matching strings remain identical to pinned main. No other branches pushed or PRs merged.

Collection and scope

WithTesting(Func<ResourceTestingContext, Task>?) runs only at testing runtime; runner configuration is independent. Replacement preserves context/path. context.TestingContext.OutputPath is the run root; context.OutputPath is <run>/<logical-resource-name>.

CaptureOutputAsync waits authoritative native completion, including failure, then drains separate durable timestamp-free DCP stdout/stderr through EOF. Both files close before exclusive output.complete; callers share the capture task and faults. Run cancellation and collector deadlines apply; caller-local completion-wait cancellation does not poison shared capture. WithTestingTimeout defaults to infinite; collection timeout does not stop other resources/collectors. No dashboard log scraping, bounded backlog, shell redirection, merged streams or unnecessary framework-report staging.

Aspire-owned capture files are Unix 0600 within CLI-owned 0700 directories. Stale artifacts/symlinked directories fail explicitly; cancellation/errors retain partial files without a completion marker. Windows inherited permissions are not validated; no completed security review is claimed.

Parsing handles Go build events, interleaved packages, parent/subtest failures, repeated invocations, durations, no-test packages, malformed/incomplete output and harvested cases despite process failure. Only actual top-level named terminal pass/fail/skip events count. Package/build/timeout failures do not invent named cases. Raw output is untruncated; normalized messages have an explicit 64 KiB truncation notice. Shared seven outcomes are preserved; only Passed/Skipped are non-failing. Capture supports one native nonterminal invocation; replicas/restarts/wrappers/retries/benchmarks/sustained fuzzing are unsupported.

The cumulative playground preserves service/source-dashboard/prior frameworks/private cleanup. Go uses standard-library fixtures, dynamic GO_SERVICE_URL, WaitFor(service) and independent GO_PLAYGROUND_FAIL=true. Source references use AspireProjectOrPackageReference, without package hives or machine-specific paths. The CLI preview remains default-off; use scoped features__testCommandEnabled=true rather than global configuration.

Validation

Current schema1 head, macOS arm64:

dotnet test --project tests/Aspire.Hosting.Go.Tests/Aspire.Hosting.Go.Tests.csproj --no-launch-profile -- --filter-class '*.GoTestResourceTests' --filter-class '*.GoTestJsonReportTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed 46 model/parser tests.

dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class '*.TestOutputCaptureTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed 12 capture tests, including deadline cancellation and no completion marker.

dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.TestRunReporterTests' --filter-class '*.TestCommandTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed 130 reporting/command tests, including exact schemaVersion1 JSON snapshots and resource-keyed output.

dotnet test --project tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj --no-launch-profile -- --filter-class '*.GoTestExportTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed 1 Go export test; no snapshot changes required.

Prior broader evidence on 45a1c623bd6686a68ed0a1c56f110f2788ea62ea, reused only where relevant sources are unchanged:

dotnet test --project tests/Aspire.Hosting.Go.Tests/Aspire.Hosting.Go.Tests.csproj --no-launch-profile -- --filter-class '*.GoTestResourceTests' --filter-class '*.GoTestJsonReportTests' --filter-class '*.GoTestExecutionTests' --filter-not-trait 'quarantined=true'
dotnet test --project tests/Aspire.Hosting.Go.Tests/Aspire.Hosting.Go.Tests.csproj --no-launch-profile -- --filter-not-method '*.GoRunPreservesVersionStampAndDebugSymbolsWhenSupported' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class '*.TestOutputCaptureTests' --filter-class '*.TestingCollectorTests' --filter-class '*.TestRunCoordinatorTests' --filter-class '*.TestRunStreamingTests' --filter-class '*.ResourceLoggerServiceTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
dotnet test --project tests/Aspire.Hosting.CodeGeneration.Go.Tests/Aspire.Hosting.CodeGeneration.Go.Tests.csproj --no-launch-profile -- --filter-method '*.TwoPassScanning*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
dotnet build playground/AspireCliTesting/apphost.cs /p:SkipNativeBuild=true --verbosity quiet

Respectively passed 54 (including eight real Go/DCP scenarios), 189 ordinary Go regressions (excluding known unrelated debugger-symbol baseline failures), 145 core/capture tests, 3 Go generation tests and cumulative AppHost build. These were not rerun for this version/documentation-only propagation; current schema assertions were rerun above.

No user's runtime/browser/terminal touched. Full source CLI smoke, keep-alive, Windows/Linux runtime and CI are not claimed passed. The separate Homebrew blocker is not resolved by this layer; foundation owner monitors CI. Historical playground success/failure predates the current contracts and is not current-head evidence. Scoped reproduction:

features__testCommandEnabled=true dotnet run --project src/Aspire.Cli/Aspire.Cli.csproj --no-launch-profile -- test --apphost playground/AspireCliTesting/apphost.cs --isolated --timeout-seconds 120 --format json --non-interactive
features__testCommandEnabled=true GO_PLAYGROUND_FAIL=true dotnet run --project src/Aspire.Cli/Aspire.Cli.csproj --no-launch-profile -- test --apphost playground/AspireCliTesting/apphost.cs --isolated --timeout-seconds 120 --format json --non-interactive

Related issue: N/A; focused Go layer of stack #22374.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21585

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21585"

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-go-testing-integration branch from 5f8399a to 82fc8bd Compare November 1, 2026 09:31
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-go-testing-integration branch from 82fc8bd to 60d175e Compare November 1, 2026 09:36
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-go-testing-integration branch from 60d175e to af6b531 Compare November 1, 2026 13:05
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-go-testing-integration branch from 0e6ab67 to 45a1c62 Compare November 23, 2026 01:08
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Keep runner configuration independent of the runtime collector, preserve shared raw capture cancellation and flat artifact paths, and verify Go timeout failures without invented named outcomes.

Co-authored-by: Copilot App <[email protected]>
Use the renamed shared context for raw capture ancestry and construction, preserve resource output destinations, and verify generated testingContext getter identities.

Co-authored-by: Copilot App <[email protected]>
Keep Go command examples invocation-scoped and adapt inherited streaming coverage to the raw capture dependency.

Co-authored-by: Copilot App <[email protected]>
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-go-testing-integration branch from 45a1c62 to 22319b0 Compare November 23, 2026 03:53
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

52 / 101 PR test projects · 4 PR jobs, from 29 changed files.

Selected PR test projects (52 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests, Aspire.Templates.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 32 of the 52 selected test projects come from a single change — tests/Aspire.Hosting.TestUtilities/Utils/TestConsoleLogsService.cs.

🧪 tests/Aspire.Hosting.TestUtilities/Utils/TestConsoleLogsService.cs (changed test)
→ 32 via the project graph

show 32

Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests

🔧 src/Aspire.Hosting/ApplicationModel/ResourceLoggerService.cs (changed source)
→ 10 via the project graph: Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (3 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Testing.Tests (2 hops), Aspire.Playground.Tests

🧪 tests/Aspire.Hosting.Tests/Cli/TestOutputCaptureTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 2 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Radius.Tests

📦 affected project Aspire.Hosting.Dotnet
→ 2 tests: Aspire.Cli.EndToEnd.Tests, Aspire.Templates.Tests

📦 affected project Aspire.Hosting.Go
→ 1 test: Aspire.Cli.EndToEnd.Tests

📄 playground/AspireCliTesting/Directory.Build.targets (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/apphost.cs (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/go-tests/go.mod (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/go-tests/service_test.go (changed)
→ 1 directly: Aspire.Playground.Tests

🔧 src/Aspire.Hosting.Go/GoRunDebugging.cs (changed source)
→ 1 directly: Aspire.Hosting.Go.Tests

🔧 src/Aspire.Hosting.Go/GoTestJsonReport.cs (changed source)
→ 1 directly: Aspire.Hosting.Go.Tests

🔧 src/Aspire.Hosting.Go/GoTestResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Go.Tests

🔧 src/Aspire.Hosting.Go/GoTestingExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.Go.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.TypeScript.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/GoTestExportTests.cs (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.TypeScript.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/GoTestExportTests.GeneratesExperimentalGoTestAndCaptureOutput.verified.txt (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.TypeScript.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/MsTestExportTests.GeneratesOneAddMsTestMethodWithTypedOptionsAndExecutableCapabilities.verified.txt (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.TypeScript.Tests

🧪 tests/Aspire.Hosting.Dotnet.Tests/MsTestCollectorTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Dotnet.Tests

🧪 tests/Aspire.Hosting.Go.Tests/GoTestExecutionTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Go.Tests

🧪 tests/Aspire.Hosting.Go.Tests/GoTestJsonReportTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Go.Tests

🧪 tests/Aspire.Hosting.Go.Tests/GoTestResourceTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Go.Tests

🧪 tests/Aspire.Hosting.Python.Tests/PytestCollectorTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Python.Tests

🧪 tests/Aspire.Hosting.Tests/Cli/TestRunCoordinatorTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/Cli/TestRunStreamingTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/Cli/TestingCollectorTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.Go
extension-e2e • src/Aspire.Hosting.Go/GoRunDebugging.cs, src/Aspire.Hosting.Go/GoTestJsonReport.cs, src/Aspire.Hosting.Go/GoTestResource.cs, src/Aspire.Hosting.Go/GoTestingExtensions.cs, src/Aspire.Hosting/ApplicationModel/ResourceLoggerService.cs, src/Aspire.Hosting/ApplicationModel/ResourceTestingContext.cs, src/Aspire.Hosting/Cli/TestOutputCapture.cs, src/Aspire.Hosting/Cli/TestRunCoordinator.cs, src/Aspire.Hosting/Dcp/DcpResourceWatcher.cs, src/Aspire.Hosting/IConsoleLogsService.cs
• affected project Aspire.Hosting.Go
polyglot • affected project Aspire.Hosting.Go
• affected project Aspire.Hosting.Azure.Provisioning
typescript-api-compat affected project Aspire.Hosting.Go

Selection computed for commit 22319b0.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Mitch Denny (mitchdenny) added a commit that referenced this pull request Nov 26, 2026
…21559)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `88c7bca539e15ae8d2fd9c2e2903b65919ab7603`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 8/10 | ↑ Eight original MSTest patches preserved
on main; follow-ups correct replica wording and accurately distinguish
collection errors from failing cases.<br>↑ Parent8457d04 passed79 MSTest
tests, including real MTP success/failure, two export tests and AppHost
build; no executable code changed since.<br>↓ 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.<br>↓ Final-head CI/native validation is pending or
running; cross-platform/full CLI behavior was not rerun locally. |
<!-- /copilot-assessment -->

## Description

Adds the experimental MSTest layer of the Aspire testing stack:
`AddMsTest`, `MsTestResource : ExecutableResource`, and `MsTestOptions`
in `Aspire.Hosting.Dotnet`. An executable MSTest project composes normal
references, environment variables and waits, and publishes individual
TRX results during `aspire test`. All new hosting testing APIs are
experimental under `ASPIRETESTING001`, with TypeScript export coverage.

Foundation #21527 is merged into main at
`16f52aeb827e6415fa1e1d318a98dcdad607bcc5`. This PR now targets `main`
at that exact revision. Current MSTest head:
`88c7bca539e15ae8d2fd9c2e2903b65919ab7603` on
`mitchdenny-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
`8457d04b28670374abc750f30749dff74bcb2fc6` and
`382b7f1d3f95c7893eb2aae0c93e936c84ed7177`, 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
`8457d04b28670374abc750f30749dff74bcb2fc6` contains current main and
exactly the eight intended MSTest patches; `git range-diff` confirms
each patch is identical to the previous head
`cdfe8f543daf1d52b5d51930ce6f7e38ceea73ea`. 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

```csharp
#pragma warning disable ASPIRETESTING001

builder.AddMsTest("api-tests", "../Api.Tests/Api.Tests.csproj")
    .WithReference(api)
    .WaitFor(api);
```

```typescript
await builder.addMsTest("api-tests", "../Api.Tests/Api.Tests.csproj")
    .withReference(api)
    .waitFor(api);
```

The preview CLI command is disabled by default. Opt in per invocation
without changing global configuration:

```bash
features__testCommandEnabled=true aspire test
```

The 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 uses `dotnet
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 AppHost
`IFileSystemService` and 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.OutputPath` is the run root;
`context.OutputPath` is the flat logical-resource directory. Only this
invocation's canonical `results.trx` is 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 cumulative
`playground/AspireCliTesting` fixture 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](https://github.com/microsoft/testfx/blob/v4.4.0/src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.Results.cs),
[MTP state
converter](https://github.com/microsoft/testfx/blob/v4.4.0/src/Platform/Microsoft.Testing.Extensions.TrxReport/Streaming/TrxTestResultExtractor.cs),
[TRX
outcomes](https://github.com/microsoft/vstest/blob/main/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestOutcome.cs).

The inherited unreleased CLI contract is schemaVersion1: resource-keyed
`testResults` contains independent execution, collector and case
observations; `testSummary` contains 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 is
`testResults[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 exact `report.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](https://github.com/microsoft/aspire/actions/runs/45747652984)
is pending,
[native45747652413](https://github.com/microsoft/aspire/actions/runs/45747652413)
and automated review are running; no current-head green CI claim is
made. The earlier parent
[CI45743335067](https://github.com/microsoft/aspire/actions/runs/45743335067)
and
[native45743334822](https://github.com/microsoft/aspire/actions/runs/45743334822)
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 `baf66756d9846c6bc7fb16179ef77c9d00940c20` passed211 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

- Is this feature complete?
  - [ ] Yes. Ready to ship.
  - [x] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [x] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [x] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [x] Yes
      - [ ] No
  - [ ] No
- Does the change make any security assumptions or guarantees?
  - [x] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [x] No
  - [ ] No

---------

Co-authored-by: Copilot App <[email protected]>

This branch has not been deployed

No deployments
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.

1 participant