Skip to content

Add experimental pytest testing integration - #21580

Draft
Mitch Denny (mitchdenny) wants to merge 47 commits into
mainfrom
mitchdenny-pytest-testing-integration
Draft

Mitch Denny (mitchdenny) wants to merge 47 commits into
mainfrom
mitchdenny-pytest-testing-integration

Conversation

@mitchdenny

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

Copy link
Copy Markdown
Member

Description

Allow Python suites to participate in common aspire test aggregation without a custom pytest plugin or separate orchestration path. This focused draft targets #21559 (mitchdenny-mstest-testing-integration at e9c90cd31f62ef07118612bd7bd2cf21ca22cc0a), depending on #21527. Current pytest head: 3a48760a9298b6ac3574825ace06796e2c625afd.

This wave inherits foundation 15048f5c78f081bbb534b0d81b842ab588966236: resource-keyed testResults/testSummary now use schemaVersion 1 with no migration or legacy compatibility. Collector-only deadlines, infinite default, experimental WithTestingTimeout and backchannel v1 remain unchanged. No runtime/Cargo API change.

Rebased only five owning commits onto the supplied parent. Four patches are identical; cumulative playground README conflict was resolved preserving pytest fixtures and the parent's corrected testResults[resourceName].outputPath wording. No stale collections[] reference remains. No declined opt-in prose changes. RunCommand and CLI strings remain identical to pinned main 79127e0afa9cb87a5ba21abf5531441a33486a39.

Adds experimental AddPytest in Aspire.Hosting.Python, returning existing PythonAppResource. All new public testing APIs use ASPIRETESTING001 with the foundation diagnostic URL. Existing Python/pip/uv/venv selection, references, waits, telemetry and environment conventions remain intact. Ordinary runs have no Aspire report flags or collection; publishing excludes the resource. Pytest is an explicit application dependency, not a global installation.

The runtime-only WithTesting(Func<ResourceTestingContext, Task>?) collector waits for completion before reading the fresh report directory allocated by the test-only OnBeforeStart hook through DI-resolved IFileSystemService. AppHost disposal owns cleanup. Managed built-in --junitxml is inserted after ordinary options and before --, overriding configuration/PYTEST_ADDOPTS destinations. Failed processes are harvested too. Only the current invocation's canonical XML is staged with CreateNew into <run>/<logical-resource-name>/pytest.xml; links, stale overwrites, missing/malformed/unsupported/inconsistent reports fail explicitly without invented tests. Replicas/restarts are rejected; retry/repeat/loop plugins remain unsupported.

JUnit failure/error/skipped/no-node map to Failed/Error/Skipped/Passed. Parameterized identities, durations, diagnostics and overlapping call/teardown outcomes are retained, not deduplicated. No hidden pass is invented for pytest counter discrepancies. Xfail is skipped, non-strict XPASS passed, strict XPASS failed. No timeout/cancellation/inconclusive verdict is inferred from text or exit status; exit 2 can mean collection abort, and all nonzero exits fail including 5. The seven inherited outcomes are Failed, Passed, Skipped, Inconclusive, Error, TimedOut and Cancelled. Only Passed/Skipped are non-failing; published failures return 23 rather than command deadline 17 or Ctrl+C 130.

Preserves cumulative playground/AspireCliTesting/apphost.cs, shared service, foundation collector, MSTest and source dashboard. Pytest uses separate fixtures, dynamic PYTEST_SERVICE_URL and independent PYTEST_PLAYGROUND_FAIL inside the inherited fixture try/finally. Local source references, dashboard opt-outs and cleanup remain intact. No other branch pushes, stack metadata/readiness changes, generated API baseline edits or user runtime actions.

Fixes # (issue)

Usage and runtime contract

#pragma warning disable ASPIRETESTING001
builder.AddPytest("api-tests", "../python-api")
    .WithUv()
    .WithArgs("tests", "-q")
    .WithReference(api)
    .WaitFor(api);
await builder.addPytest("api-tests", "../python-api")
    .withUv()
    .withArgs(["tests", "-q"])
    .withReference(api)
    .waitFor(api);

Declare pytest in pyproject.toml or requirements.txt. WithUv synchronizes through its installer child then launches the venv executable directly, not uv run. The preview CLI command defaults off; opt in per invocation, including JSON/failure/keepalive/dashboard opt-out commands, without saved/global configuration:

features__testCommandEnabled=true aspire test

Custom collectors await context.WaitForCompletionAsync() before staging into context.OutputPath and publishing. context.TestingContext.OutputPath is the run root; context.OutputPath is the logical resource folder. TypeScript exposes testingContext(): TestingContextPromise and outputPath() getters. No old aliases remain. Collectors run only during testing, not model definition. Later WithTesting replaces the callback; marker-only clears it while retaining context/path. Collector replacement does not remove pytest launch configuration or cleanup. No public model-time output-path API is introduced.

Validation

Current head 3a48760a9298b6ac3574825ace06796e2c625afd passed 303 focused tests on macOS arm64 with the repository SDK first on PATH:

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

Passed: 170 Python tests.

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

Passed: 3 scanner/export tests.

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 resource-keyed schemaVersion 1 output. No coupled pytest JSON reader/version assertion required migration. Search found no remaining collections[] or schemaVersion 2 reference in pytest sources/tests or cumulative playground documentation.

Reused, not rerun: prior head 060e28c1a8c6db350ec4f9c137bc0e1c2521c4ed had 428 tests plus cumulative AppHost build passed (Python170, real pytest12, exports2, core114, reporter130). Scanner-correction head 4293aa2510cc8d82c88074b489a9082e5a32a278 had 173 Python/scanner/export checks passed. Framework runtime source remains unchanged; no new user runtime actions. Current git diff --check passed, clean tree verified. CI is not claimed green; Homebrew blocker is tracked separately by the coordinator.

Security considerations

Runs user-declared dependencies through the existing launcher and parses runner XML. Temporary runner files are AppHost-owned; resource directories are private (0700 Unix). Staged reports use copy-writer permissions, not a per-file 0600 guarantee. DTD/external resolution prohibited, XML size bounded, links rejected, stale destinations not overwritten. Reports can contain sensitive data and are not automatically uploaded. API/security review remains pending for this draft.

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

Reuse the run lifecycle, wait for all annotated test resources, and return reliable aggregate outcomes with orderly shutdown.

Co-authored-by: Copilot App <[email protected]>
Render test AppHost information as append-only log lines and publish completion summaries before keep-alive inspection. Reuse shared AppHost lifecycle infrastructure without inheriting RunCommand.

Co-authored-by: Copilot App <[email protected]>
Restore RunCommand and its localized resources to the PR base. Keep finite testing launch, cancellation, completion, inspection and diagnostic capture test-owned using existing project/backchannel services.

Co-authored-by: Copilot App <[email protected]>
@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

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 -- 21580

Or

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

@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.

Refresh the testing foundation against main and document how to select the repository-built modern dashboard in the shared playground. Preserve RunCommand and its resources unchanged relative to main.

Co-authored-by: Copilot App <[email protected]>
@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.

Follow the existing file-based playground's reserved dashboard resource pattern instead of relying on build metadata that CLI bundle paths can override. Retain the shared playground opt-out and explicit DcpPublisher binary selection.

Co-authored-by: Copilot App <[email protected]>
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-pytest-testing-integration branch from e5b311d to 0b90115 Compare November 1, 2026 09:27
@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-pytest-testing-integration branch from 0b90115 to 8d38669 Compare November 1, 2026 09:32
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-pytest-testing-integration branch from 060e28c to 4293aa2 Compare November 23, 2026 01:02
@github-actions

This comment has been minimized.

Keep the resource-keyed report at schema version 1 and document its execution, collection, case and summary fields accurately.

Co-authored-by: Copilot App <[email protected]>
Reuse the foundation HTTP service and add an executable MSTest fixture with finalized TRX collection, skips and opt-in failure. Document source CLI and reporting commands.

Co-authored-by: Copilot App <[email protected]>
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]>
Stage fresh invocation reports after completion with AppHost-owned temporary cleanup, and adapt fixtures to the runtime-only testing contract.

Co-authored-by: Copilot App <[email protected]>
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-pytest-testing-integration branch from 4293aa2 to 3a48760 Compare November 23, 2026 03:50
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

11 / 101 PR test projects · 2 PR jobs, from 17 changed files.

Selected PR test projects (11 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Tests, Aspire.Playground.Tests

Selected PR jobs (2)

polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 9 of the 11 selected test projects come from a single change — src/Aspire.Hosting.Python/PytestHostingExtensions.cs.

🔧 src/Aspire.Hosting.Python/PytestHostingExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.Python.Tests
→ 8 via the project graph: Aspire.Hosting.Azure.Kubernetes.Tests (3 hops), Aspire.Hosting.Azure.Tests (2 hops), Aspire.Hosting.Blazor.Tests (2 hops), Aspire.Hosting.Dotnet.Tests (2 hops), Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Radius.Tests (2 hops), Aspire.Hosting.Tests, Aspire.Playground.Tests (2 hops)

📦 affected project Aspire.Hosting.Python
→ 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/pytest-tests/pyproject.toml (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/pytest-tests/test_service.py (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/pytest-tests/uv.lock (changed)
→ 1 directly: Aspire.Playground.Tests

🔧 src/Aspire.Hosting.Python/PytestJunitReport.cs (changed source)
→ 1 directly: Aspire.Hosting.Python.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/PytestExportTests.cs (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.TypeScript.Tests

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

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

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

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

🧪 tests/Aspire.Hosting.Python.Tests/Snapshots/PytestJunitReportTests.BuiltInOutcomesPreserveParameterizedNamesDurationsAndDiagnostics.verified.txt (changed test)
→ 1 directly: Aspire.Hosting.Python.Tests

🧪 tests/Aspire.Hosting.Python.Tests/Snapshots/PytestJunitReportTests.OverlappingTeardownOutcomesAreNotDeduplicatedOrDropped.verified.txt (changed test)
→ 1 directly: Aspire.Hosting.Python.Tests

🧪 tests/Aspire.Hosting.Python.Tests/Snapshots/PytestJunitReportTests.PassingCallWithTeardownErrorDoesNotInventAHiddenPassingOutcome.verified.txt (changed test)
→ 1 directly: Aspire.Hosting.Python.Tests

🧪 tests/Aspire.Hosting.Python.Tests/Snapshots/PytestResourceTests.PublishOmitsPytestAndDoesNotAllocateTestingOutputOrInstallers.verified.json (changed test)
→ 1 directly: Aspire.Hosting.Python.Tests

Job reasons

Job Triggered by
polyglot affected project Aspire.Hosting.Python
typescript-api-compat affected project Aspire.Hosting.Python

Selection computed for commit 3a48760.

@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.

Base automatically changed from mitchdenny-mstest-testing-integration to main November 26, 2026 04:43
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]>
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 26, 2026 04:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active findings show that undercounted test totals can publish incorrect Passed results, while deferred arguments can misplace the managed report option and bypass reserved-option validation.

2 open issues
What changed in this PR

Adds experimental pytest integration to Aspire’s shared testing workflow, building on the testing foundation and MSTest layer. Python suites use existing resource orchestration and publish built-in JUnit results without a custom pytest plugin.

Changes:

  • Adds AddPytest, managed report collection, outcome mapping, and usage documentation.
  • Includes shared testing lifecycle, remote callback, CLI launch, and reporting support from the underlying stack.
  • Adds parser and export coverage, reporting snapshots, and a combined playground.
File Description
tests/​Aspire.Hosting.Tests/​Cli/​TestRunStreamingTests.cs Tests resource outcome streaming.
tests/​Aspire.Hosting.Tests/​Cli/​TestRunCoordinatorEndToEndTests.cs Tests backchannel completion and cancellation.
tests/​Aspire.Hosting.RemoteHost.Tests/​JsonRpcCallbackInvokerTests.cs Tests collector lifetime and timeout overrides.
tests/​Aspire.Hosting.RemoteHost.Tests/​CapabilityDispatcherTests.cs Tests callback policy dispatch.
tests/​Aspire.Hosting.RemoteHost.Tests/​CallbackProxyTests.cs Tests timeout-aware callback proxies.
tests/​Aspire.Hosting.RemoteHost.Tests/​AttributeDataReaderTests.cs Tests timeout attribute metadata reading.
tests/​Aspire.Hosting.Python.Tests/​Snapshots/​PytestResourceTests.PublishOmitsPytestAndDoesNotAllocateTestingOutputOrInstallers.verified.json Records pytest exclusion from publishing.
tests/​Aspire.Hosting.Python.Tests/​Snapshots/​PytestJunitReportTests.PassingCallWithTeardownErrorDoesNotInventAHiddenPassingOutcome.verified.txt Records teardown-error-only results.
tests/​Aspire.Hosting.Python.Tests/​Snapshots/​PytestJunitReportTests.OverlappingTeardownOutcomesAreNotDeduplicatedOrDropped.verified.txt Records overlapping outcomes.
tests/​Aspire.Hosting.Python.Tests/​Snapshots/​PytestJunitReportTests.BuiltInOutcomesPreserveParameterizedNamesDurationsAndDiagnostics.verified.txt Records normalized pytest results.
tests/​Aspire.Hosting.Python.Tests/​PytestJunitReportTests.cs Tests JUnit parsing and validation.
tests/​Aspire.Hosting.Dotnet.Tests/​Snapshots/​MsTestTrxReportTests.NormalizesDataRowsOutcomesDurationsAndEscapedDiagnostics.verified.txt Records normalized MSTest results.
tests/​Aspire.Hosting.Dotnet.Tests/​Helpers/​MsTestReportFixture.cs Supplies synthetic TRX fixtures.
tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests/​Snapshots/​PytestExportTests.GeneratesExperimentalAddPytestWithPythonResourceCapabilities.verified.txt Records the generated pytest method.
tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests/​Snapshots/​MsTestExportTests.GeneratesOneAddMsTestMethodWithTypedOptionsAndExecutableCapabilities.verified.txt Records MSTest and collector contracts.
tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests/​Snapshots/​HostingContainerResourceCapabilities.verified.txt Adds testing capabilities to the snapshot.
tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests/​PytestExportTests.cs Verifies experimental pytest export.
tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests/​MsTestExportTests.cs Verifies MSTest TypeScript generation.
tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests/​AtsTypeScriptCodeGeneratorTests.cs Checks shared testing export contracts.
tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests/​Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj References Python hosting for export tests.
tests/​Aspire.Cli.Tests/​Utils/​CliTestHelper.cs Registers the test command for tests.
tests/​Aspire.Cli.Tests/​TestServices/​TestAppHostCliBackchannel.cs Models testing backchannel operations.
tests/​Aspire.Cli.Tests/​TestServices/​FakeAppHostServerSession.cs Models server shutdown and exit status.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.UnknownTerminalExitCodeIsExplicitWithoutInventingTestCounts.verified.txt Records unknown-exit reporting.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.TestLogMarkupEscapesNamesAndRespectsConsoleColorCapabilities_color=False.verified.txt Records escaped, color-free output.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.SummaryPreservesReplicasAndFinalOutcomesBeforeReturningCompletion_supportsLinks=True.verified.json Records replica summary with links enabled.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.SummaryPreservesReplicasAndFinalOutcomesBeforeReturningCompletion_supportsLinks=False.verified.json Records replica summary with links disabled.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.ResourceTransitionsAndDelayedTestResultsHaveDistinctRenderingAndFinalCounts.verified.txt Records transitions and final result counts.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.ResourceKeyedReportPreservesReplicasPartialCasesAndResourceOnlyFailures.verified.json Records resource-keyed mixed results.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.ResourceCountsWaitForEveryReplicaAndKeepProcessAndCollectorFailuresIndependent_processFails=True.verified.txt Records independent process failure.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.ResourceCountsWaitForEveryReplicaAndKeepProcessAndCollectorFailuresIndependent_processFails=False.verified.txt Records independent collector failure.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.InterruptedCollectionShowsPublishedSoFarInsteadOfFinalTotals_exitCode=17.verified.txt Records partial results on timeout.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.InterruptedCollectionShowsPublishedSoFarInsteadOfFinalTotals_exitCode=130.verified.txt Records partial results on cancellation.
tests/​Aspire.Cli.Tests/​Testing/​Snapshots/​TestRunReporterTests.AllPublishedOutcomesRetainSpecificNamesAndTotalsInJson.verified.json Records all seven result outcomes.
tests/​Aspire.Cli.Tests/​Projects/​GuestAppHostProjectTests.cs Tests guest test-run shutdown ownership.
tests/​Aspire.Cli.Tests/​Projects/​DotNetAppHostProjectTests.cs Tests output-path precedence and non-watch launch.
tests/​Aspire.Cli.Tests/​DotNet/​ProcessInvocationOptionsTests.cs Checks launch-option cloning.
tests/​Aspire.Cli.Tests/​DotNet/​DotNetCliRunnerTests.cs Tests CLI-owned process launch.
tests/​Aspire.Cli.Tests/​Configuration/​KnownFeaturesTests.cs Tests default-off feature configuration.
tests/​Aspire.Cli.Tests/​Commands/​RootCommandTests.cs Tests command opt-in registration.
tests/​Aspire.Cli.Tests/​Commands/​PublishCommandPromptingIntegrationTests.cs Updates the backchannel test implementation.
src/​Shared/​KnownConfigNames.cs Defines the testing output setting.
src/​Shared/​CliExitCodes.cs Defines test-run failure exit code 23.
src/​Aspire.TypeSystem/​HostingTypeHelpers.cs Identifies callback timeout attributes.
src/​Aspire.TypeSystem/​AttributeDataReader.cs Reads and validates timeout metadata.
src/​Aspire.Hosting/​TestResourceBuilderExtensions.cs Adds testing markers, collectors, and deadlines.
src/​Aspire.Hosting/​DistributedApplicationBuilder.cs Registers the test coordinator.
src/​Aspire.Hosting/​DistributedApplication.cs Starts collectors after model setup.
src/​Aspire.Hosting/​Backchannel/​BackchannelDataTypes.cs Defines testing events and outcome records.
src/​Aspire.Hosting/​Backchannel/​AppHostRpcTarget.cs Exposes testing completion and streaming.
src/​Aspire.Hosting/​Ats/​AspireCallbackTimeoutAttribute.cs Adds callback timeout policy metadata.
src/​Aspire.Hosting/​ApplicationModel/​TestResult.cs Defines framework-neutral results and outcomes.
src/​Aspire.Hosting/​ApplicationModel/​TestingDiagnostics.cs Centralizes experimental testing diagnostics.
src/​Aspire.Hosting/​ApplicationModel/​TestingContext.cs Exposes the invocation output directory.
src/​Aspire.Hosting/​ApplicationModel/​TestingAnnotation.cs Stores collector configuration and deadline.
src/​Aspire.Hosting/​ApplicationModel/​ResourceTestingContext.cs Supports completion waits and result publication.
src/​Aspire.Hosting.RemoteHost/​JsonRpcCallbackInvoker.cs Exposes explicit timeout invocation.
src/​Aspire.Hosting.RemoteHost/​ICallbackInvoker.cs Adds the timeout-aware invocation contract.
src/​Aspire.Hosting.RemoteHost/​Ats/​CapabilityDispatcher.cs Passes callback timeout metadata.
src/​Aspire.Hosting.RemoteHost/​Ats/​AtsMarshaller.cs Applies timeout policy when creating proxies.
src/​Aspire.Hosting.Python/​README.md Documents pytest setup and collection behavior.
src/​Aspire.Hosting.Python/​PytestJunitReport.cs Stages and parses pytest JUnit reports.
src/​Aspire.Hosting.Python/​PytestHostingExtensions.cs Adds pytest resource launch and collection setup.
src/​Aspire.Hosting.Dotnet/​README.md Documents experimental MSTest resources.
src/​Aspire.Hosting.Dotnet/​MsTestResource.cs Defines an executable MSTest resource.
src/​Aspire.Hosting.Dotnet/​MsTestOptions.cs Defines MSTest build and runner options.
src/​Aspire.Hosting.Dotnet/​MsTestHostingExtensions.cs Configures MSTest execution and collection.
src/​Aspire.Hosting.Dotnet/​Aspire.Hosting.Dotnet.csproj Enables integration analyzers.
src/​Aspire.Cli/​Projects/​GuestAppHostProject.cs Preserves test configuration and server exit status.
src/​Aspire.Cli/​Projects/​DotNetAppHostProject.cs Keeps test launch under CLI control.
src/​Aspire.Cli/​Projects/​AppHostProjectContext.cs Identifies finite test runs.
src/​Aspire.Cli/​Program.cs Registers the test command service.
src/​Aspire.Cli/​KnownFeatures.cs Adds the default-off testing feature.
src/​Aspire.Cli/​DotNet/​DotNetCliRunner.cs Preserves test launch ownership and output precedence.
src/​Aspire.Cli/​Commands/​RootCommand.cs Gates test command registration.
src/​Aspire.Cli/​Backchannel/​BackchannelJsonSerializerContext.cs Registers test-event stream serialization.
src/​Aspire.Cli/​Backchannel/​AppHostCliBackchannel.cs Adds testing RPC client operations.
playground/​AspireCliTesting/​service/​service.cs Provides a shared HTTP test target.
playground/​AspireCliTesting/​pytest-tests/​test_service.py Demonstrates pytest service checks and outcomes.
playground/​AspireCliTesting/​pytest-tests/​pyproject.toml Declares the pytest dependency and discovery path.
playground/​AspireCliTesting/​mstest-tests/​ServiceTests.cs Demonstrates MSTest service checks and outcomes.
playground/​AspireCliTesting/​mstest-tests/​Playground.MSTest.csproj Configures an executable MSTest fixture.
playground/​AspireCliTesting/​mstest-tests/​Directory.Build.targets Isolates fixture runner targets.
playground/​AspireCliTesting/​mstest-tests/​Directory.Build.props Isolates fixture build properties.
playground/​AspireCliTesting/​foundation-tests/​tests.cs Provides a framework-neutral service probe.
playground/​AspireCliTesting/​Directory.Build.targets Wires local hosting project references.
playground/​AspireCliTesting/​Directory.Build.props Imports shared playground build properties.
playground/​AspireCliTesting/​aspire.config.json Selects the playground AppHost.
playground/​AspireCliTesting/​apphost.cs Composes service, probe, MSTest, and pytest resources.

Review effort: Balanced

Comment on lines +175 to +176
ReadCount(suite, "skipped") != skipped || tests > (long)results.Count - initialCount + errors ||
tests == 0 && results.Count != initialCount)
Comment on lines +133 to +135
ValidateArguments(context.Args);
var separator = context.Args.IndexOf("--");
context.Args.Insert(separator < 0 ? context.Args.Count : separator,

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.

2 participants