Repository navigation
[docs] Document recursive MTP test runner invocation guard in testing docs - #1804
aspire-repo-bot[bot] wants to merge 1 commit into
Conversation
Adds a troubleshooting section to the advanced testing scenarios page explaining why Aspire.AppHost.Sdk test projects can recursively invoke the test runner via DistributedApplicationTestingBuilder.CreateAsync, and how to fix it (Microsoft.NET.Sdk + ProjectReference, dynamic assembly loading, or DistributedApplicationTestingBuilder.Create()). Documents microsoft/aspire#20573 Co-authored-by: Copilot <[email protected]>
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
docs-pr-reviewer report — [partial — phase A: key claims evaluated; phase B: not run (docs site was not served in this automated run)]Recommendation: approve Source used: microsoft/aspire#20573 (merged 2026-10-01) Phase A — claims
Phase B — doc-testerNot run; rendering of the changed pages is not browser-checked. 🤖 Posted by aspire.dev - squad (AI Agent) |
There was a problem hiding this comment.
🟡 Changes recommended
The documentation quotes the wrong diagnostic for generated project metadata and links to an entry-point-based factory example rather than documenting Create(), leaving the remediation misleading.
2 open issues
What changed in this PR
Extends the testing documentation to explain the recursive Microsoft.Testing.Platform test-runner guard introduced in microsoft/aspire#20573.
Changes:
- Describes how using
Aspire.AppHost.Sdkin a test project can cause recursive test execution. - Adds an exception-message example and three remediation options.
| File | Description |
|---|---|
src/frontend/src/content/docs/testing/advanced-scenarios.mdx |
Adds troubleshooting guidance for test-project SDK configuration and recursive entry-point invocation. |
Review effort: Balanced
| `DistributedApplicationTestingBuilder.CreateAsync` detects this condition before invoking the entry point and throws `InvalidOperationException` with a message that explains the problem and the fix: | ||
|
|
||
| ```text | ||
| The assembly 'MyTests' is a Microsoft.Testing.Platform test application. Invoking its entry point from DistributedApplicationFactory would recursively run the test application. Test projects should use Microsoft.NET.Sdk instead of Aspire.AppHost.Sdk and reference the AppHost project so the entry point type belongs to the AppHost executable assembly. Alternatively, use DistributedApplicationTestingBuilder.Create to construct the application without invoking an entry point. |
|
|
||
| - Make sure the test project's SDK is `Microsoft.NET.Sdk`, and that it has a `<ProjectReference>` to the AppHost project so `Projects.MyAppHost` resolves to the AppHost's assembly, not the test assembly. | ||
| - If the AppHost is discovered dynamically at runtime, load its assembly directly and pass a type from that assembly to `CreateAsync(Type)` instead of relying on the generated `Projects` type. | ||
| - If you don't need the entry point invoked at all, use [`DistributedApplicationTestingBuilder.Create()`](/testing/manage-app-host/#use-the-distributedapplicationfactory-class) to construct the application without invoking an entry point. |

Documents changes from microsoft/aspire#20573
@danegstaTarget branch: Targeting
release/17.0based on the source PR milestone17.0(exact match onmicrosoft/aspire.dev).Why this is needed
microsoft/aspire#20573 adds a safety check to
DistributedApplicationTestingBuilder.CreateAsyncthat detects when a Microsoft.Testing.Platform test project is itself built withAspire.AppHost.Sdk. In that situation the generatedProjects.*type can belong to the test application instead of the AppHost, and invoking its entry point recursively re-runs the entire test suite (potentially leaving stray AppHost/DCP processes running). The fix throws a clearInvalidOperationExceptioninstead of silently recursing.This is a new, previously undocumented failure mode and diagnostic message that users of
DistributedApplicationTestingBuildercan now hit, so the testing docs need to explain the symptom and the fix.What changed
Added a new "Avoid building test projects with
Aspire.AppHost.Sdk" section tosrc/frontend/src/content/docs/testing/advanced-scenarios.mdx(alongside the existing "File-based AppHost limitations" section), covering:Aspire.AppHost.Sdkinstead ofMicrosoft.NET.Sdk.InvalidOperationExceptionmessage users will see.Microsoft.NET.Sdkwith a<ProjectReference>to the AppHost, load the AppHost assembly dynamically and pass a type toCreateAsync(Type), or useDistributedApplicationTestingBuilder.Create()when no entry-point invocation is needed.Files modified
src/frontend/src/content/docs/testing/advanced-scenarios.mdx(updated)No new pages were created; this extends an existing troubleshooting-style page that already documents a related AppHost-testing limitation.