Skip to content

Add Maven JUnit support to aspire test - #21675

Draft
Mitch Denny (mitchdenny) wants to merge 3 commits into
mitchdenny-rust-testing-integrationfrom
mitchdenny-java-testing-integration
Draft

Mitch Denny (mitchdenny) wants to merge 3 commits into
mitchdenny-rust-testing-integrationfrom
mitchdenny-java-testing-integration

Conversation

@mitchdenny

@mitchdenny Mitch Denny (mitchdenny) commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Description

Java suites can participate in aspire test alongside .NET, Python, Go and Rust resources, with individual JUnit outcomes in the common summary and finalized XML retained as artifacts.

This Java layer is the final layer of stack 22374: #21527, #21559, #21580, #21585, #21587, #21675. Dashboard #21646 is closed and removed, not part of this propagation. The November 23 schema-1/README correction propagation rebases Java's three owned commits onto exact Rust af6a2e7e6cbacd68e9832185f51d8592e3d1ccb2 (mitchdenny-rust-testing-integration), inheriting Go 22319b0a22b153e4f4368cfd2225634010ff02aa, foundation 15048f5c78f081bbb534b0d81b842ab588966236 and pinned main 79127e0afa9cb87a5ba21abf5531441a33486a39. Java head: 5fa69a4d21e44d8493bbff545bbef15d2ba61c26 (mitchdenny-java-testing-integration). Foundation remains ready and all five upper layers remain draft; bases and metadata are preserved.

Rebased from Java b0b23ce03f5ead4defca79f4b447dfddbddef34f using verified historical Rust boundary 7b94df1e6a66b7c746147091740d85092af8c659, not a newly inferred merge-base. All three Java patches are range-diff identical, with no conflicts or new Java edits. The inherited playground README now points to testResults[resourceName].outputPath; cumulative Java fixture content is preserved and declined opt-in prose edits were not introduced. The export test retains withTestingTimeout(timeout) coverage on Java promises. No Java-owned JSON reader/assertion has a schema version to change; runtime events remain the unchanged v1 backchannel contract. Maven/JUnit behavior, parser safety, seven outcomes, flat artifact layout and callback policy remain intact. RunCommand and its strings match pinned main. No dashboard, native-stack membership/order, generated API baseline or unrelated CI changes are introduced by this layer. No tracking issue was requested.

Inherited testing timeouts default to infinite and are enforced for collectors when configured through WithTestingTimeout. CLI JSON uses schemaVersion 1 with resource-keyed testResults, nested testCases, collector status/error, output path, execution and optional replicas; testSummary contains overall outcomes and actual case counts. This is the initial resource-keyed contract, not a legacy compatibility or migration mode. Observed partial cases survive collection failure, and resources without cases do not fabricate case counts. Command deadlines and output capture preserve cancellation. The proposed AddCargoTest API remains a specification only; this wave introduces no runtime or Cargo API change.

CI is not claimed green. The foundation owner is monitoring remote CI, including a separate Homebrew CI blocker. The local missing-JDK runtime limit is distinct from that blocker; historical runtime results below are not represented as current-snapshot passes.

Fixes # (issue)

User-facing usage

The preview CLI command is disabled by default. Enable it per invocation, without changing saved user configuration:

features__testCommandEnabled=true aspire test --apphost apphost.cs

C# AppHost:

#pragma warning disable ASPIRETESTING001
builder.AddJavaApp("java-tests", "../java-tests")
    .WithMavenGoal("test", "--batch-mode", "--no-transfer-progress")
    .WithJUnitTesting()
    .WithEnvironment("JAVA_SERVICE_URL", service.GetEndpoint("http"))
    .WaitFor(service);

TypeScript AppHost:

const tests = await builder.addJavaApp("java-tests", "../java-tests");
await tests.withMavenGoal("test", ["--batch-mode", "--no-transfer-progress"]);
await tests.withJUnitTesting();
await tests.withEnvironment("JAVA_SERVICE_URL", service.getEndpoint("http"));
await tests.waitFor(service);

WithJUnitTesting() is exported and experimental (ASPIRETESTING001). This first adapter supports single-module Maven Surefire/JUnit, not Gradle, Failsafe, reactor builds, retries, terminals, replicas or restarts. JUnit is the framework; the project's existing Maven wrapper/Surefire plugin launches tests and writes standard XML. Aspire does not install a framework or rewrite/copy the source tree.

A documented, environment-activated POM profile sets Surefire's reportsDirectory to ${env.ASPIRE_JUNIT_REPORT_DIRECTORY}. This is explicit plugin configuration, not an ineffective -Dsurefire.reportsDirectory switch. Only testing assigns a fresh private runner directory; normal Maven runs retain their usual target/surefire-reports configuration. The playground includes a pinned Maven 3.9.9 wrapper, JUnit Jupiter 5.12.2 and Surefire 3.5.3 (JDK 17+).

The runtime callback waits for process completion, including nonzero exits, then stages only fresh top-level TEST-*.xml files into <run>/<logical-resource-name>. It translates explicit failure/error/skipped elements to Failed/Error/Skipped, otherwise Passed; preserves class-qualified/parameterized names, durations and diagnostics; and validates counters and identities across the complete report set before publishing. Missing, malformed, unknown, inconsistent or duplicate reports fail explicitly without inventing cases for build/no-test failures. Process failure remains authoritative; exception text does not imply timeout/cancellation outcomes. Replacing the collector preserves independent launch-time report routing and disposal cleanup. The inherited TestingContext, seven outcomes and flat output layout remain intact.

The cumulative playground reuses its shared service, independent failure switches, cleanup and source-dashboard wiring. Previously validated normal execution reports 13 passed, 0 failed, 4 skipped; JAVA_PLAYGROUND_FAIL=true reports 12 passed, 1 failed, 4 skipped and CLI exit 23, with every other resource still passing. These runtime scenarios were not rerun after the main refresh because no usable JDK is installed.

Java's single-invocation guards use the same hosting-internal launch annotations as Go/Rust. Granting corresponding friend access also removes redundant source-shared utility definitions that would otherwise conflict with the now-visible core types.

Validation

Current November 23 schema-1 snapshot, Java head 5fa69a4d21e44d8493bbff545bbef15d2ba61c26, on macOS/arm64:

  • ./restore.sh — passed.
  • dotnet test --project tests/Aspire.Hosting.Java.Tests/Aspire.Hosting.Java.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 421 tests, including existing Java regressions plus model/API/replacement, parsing and artifact-safety coverage.
  • dotnet test --project tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj --no-launch-profile -- --filter-method '*.GeneratesExperimentalJUnitTestingOnJavaResources' --filter-method '*.TwoPassScanning_*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 5 tests, including the generated Java timeout export and affected SDK snapshot. The received timeout signature was reviewed and accepted; the final rerun passed.
  • dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.TestCommandTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 79 tests, including schemaVersion 1 resource-keyed reporting, partial results, actual counts, deadlines and persisted/live output.
  • Real Maven/JUnit scenarios and cumulative CLI runtime — not rerun: blocked by missing JDK. /usr/bin/java -version and /usr/libexec/java_home -V report no runtime; conventional Homebrew/Temurin JDK locations and prior workspace-owned tool directories contain no usable JDK. No global installation/configuration change was made.

Historical evidence, not current-main validation:

  • Preceding Java head b0b23ce03f5ead4defca79f4b447dfddbddef34f, Rust 7b94df1e6a66b7c746147091740d85092af8c659: dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class '*.TestRunCoordinatorTests' --filter-class '*.TestRunCoordinatorEndToEndTests' --filter-class '*.TestRunStreamingTests' --filter-class '*.TestingCollectorTests' --filter-class '*.TestOutputCaptureTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 137 tests; dotnet build playground/AspireCliTesting/apphost.cs — passed. Core/Java runtime sources are unchanged in this schema-number/README correction wave; these commands were not rerun here.
  • Java 0b45856c614c4132e63a1dfe54e651edec34a5e4, based on Rust 3a800950cd28e8eeac7f27b149de96e199e51a78 and foundation 8554a7755ab0a241fc10bd3ffb37ff1c9814ba45: dotnet test --project tests/Aspire.Hosting.RemoteHost.Tests/Aspire.Hosting.RemoteHost.Tests.csproj --no-launch-profile -- --filter-class '*.JsonRpcCallbackInvokerTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 7 tests, including the corrected disconnect assertion; Java regular suite also passed 421.
  • c3 Java d05249ff21199b3698ffb7e53373dbe46ce67f52, based on Rust 4139921843de02764683f31a0a256b52fe358568 and foundation c3f7e721be746054e7f963a20e3b2d45a7b9f8e3: dotnet test --project tests/Aspire.Hosting.Java.Tests/Aspire.Hosting.Java.Tests.csproj --no-launch-profile -- --filter-class '*.JUnitIntegrationTests' --filter-not-trait 'quarantined=true' — passed, 7 real DCP/Maven scenarios with workspace-local Temurin JDK 21: passing, assertion failure, exception, all-selected-skipped, no matching tests, compilation failure and disabled reporting profile/ordinary target-directory fallback. These verified multiple classes, parameterized invocations, stale-report exclusion, byte-preserving staging, shared-service calls and cleanup.
  • Same c3 head: features__testCommandEnabled=true ./run-aspire.sh test --apphost playground/AspireCliTesting/apphost.cs --isolated --timeout-seconds 240 --format json --non-interactive — passed, exit 0, 13/0/4 counts, all six testing resources and collectors passing, source dashboard enabled. Broader callback suite passed 213, core 115, export 1.
  • Earlier Java fbd765a91b8e62838c5fde81b4152fa4cad54ec0 (Rust 5ed455ba1a6429fc23bdedd543c0ac4a192aa924): features__testCommandEnabled=true JAVA_PLAYGROUND_FAIL=true ./run-aspire.sh test --apphost playground/AspireCliTesting/apphost.cs --isolated --timeout-seconds 240 --format json --non-interactive — expected exit 23, 12/1/4 counts, only Java failing and all six collectors complete. CLI feature/guest/testing 334 and core 100 tests passed in that wave.

Earlier Java-layer validation passed 344 TestTriggerMap tests and confirmed that evaluated MSBuild Content items attribute the copied POM, wrapper and Java sources to Aspire.Hosting.Java.Tests; the production selector selected that consumer plus the existing playground route with no unattributed inputs. Those inputs and routing are unchanged, so no hand-maintained routing entry was added. Windows/Linux execution, the full consolidated TypeScript terminal E2E, and green remote CI are not claimed here.

Security considerations

This launches the existing project-owned Maven wrapper with structured arguments, passes a private report directory through an environment variable, reads runner-produced XML, and stages raw reports into the inherited private testing-output hierarchy. XML external entities/DTDs are prohibited and document size is bounded. Report-directory/report-file links and existing destination files are rejected; filenames come only from top-level enumeration, never XML paths. AppHost disposal cleans fresh runner files even when the collector is replaced. No new listener, authentication or authorization mechanism is added.

Raw Surefire reports can contain JVM properties, stdout/stderr and sensitive test diagnostics; they are retained as artifacts without redaction, inside the private resource directory with copy-writer file permissions. Maven's dependency downloads/caches and project build outputs retain their existing conventions. Broader testing threat modeling/security review remains separate and is not claimed complete here.

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

github-actions Bot commented Nov 2, 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 2, 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 2, 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 2, 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 -- 21675

Or

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

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 2, 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 2, 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 2, 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-java-testing-integration branch from fbd765a to d05249f Compare November 2, 2026 09:45
@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-java-testing-integration branch from d05249f to 0b45856 Compare November 2, 2026 09:57
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 2, 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 2, 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 2, 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) marked this pull request as draft November 3, 2026 03:10
@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

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-java-testing-integration branch from 825d9ae to 4780487 Compare November 18, 2026 22:09
@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-java-testing-integration branch from 4780487 to b0b23ce Compare November 23, 2026 01:19
@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.

Collect fresh Surefire reports through the existing Java wrapper launch, export the experimental helper, and extend the cumulative testing playground with a shared-service JUnit fixture.

Co-authored-by: Copilot App <[email protected]>
Keep the Java CLI example aligned with the inherited disabled-by-default testing feature gate without changing user configuration.

Co-authored-by: Copilot App <[email protected]>
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-java-testing-integration branch from b0b23ce to 5fa69a4 Compare November 23, 2026 04:01
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

53 / 101 PR test projects · 4 PR jobs, from 19 changed files.

Selected PR test projects (53 / 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, Infrastructure.Tests

Selected PR jobs (4)

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


How these were chosen — grouped by what changed

⚠️ 49 of the 53 selected test projects come from a single change — src/Aspire.Hosting/Aspire.Hosting.csproj.

🔧 src/Aspire.Hosting/Aspire.Hosting.csproj (changed source)
→ 1 directly: Infrastructure.Tests
→ 48 via the project graph

show 48

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

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

📄 playground/AspireCliTesting/java-tests/.mvn/wrapper/maven-wrapper.properties (changed)
→ 1 directly: Aspire.Playground.Tests
→ 1 via the project graph: Aspire.Hosting.Java.Tests

📦 affected project Aspire.Hosting.Java
→ 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/java-tests/mvnw (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/java-tests/mvnw.cmd (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/java-tests/pom.xml (changed)
→ 1 directly: Aspire.Playground.Tests

📄 playground/AspireCliTesting/java-tests/src/test/java/dev/aspire/ServiceTest.java (changed)
→ 1 directly: Aspire.Playground.Tests

🔧 src/Aspire.Hosting.Java/Aspire.Hosting.Java.csproj (changed source)
→ 1 directly: Aspire.Hosting.Java.Tests

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

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

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

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

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

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

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

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

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.AppHost
extension-e2e • src/Aspire.Hosting.Java/Aspire.Hosting.Java.csproj, src/Aspire.Hosting.Java/JUnitTestingExtensions.cs, src/Aspire.Hosting.Java/SurefireJUnitReport.cs, src/Aspire.Hosting/Aspire.Hosting.csproj
• affected project Aspire.Hosting.Java
polyglot • affected project Aspire.Hosting.Java
• affected project Aspire.Hosting.Azure.Provisioning.KeyVault
typescript-api-compat affected project Aspire.Hosting.Java

Selection computed for commit 5fa69a4.

@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