[VS Code] Add a command to scaffold Aspire integration test projects
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
Aspire provides `aspire-mstest`, `aspire-nunit`, and `aspire-xunit` project templates, and the CLI exposes them through the grouped `aspire-test` template. The VS Code extension provides guided commands for creating an Aspire app, initializing Aspire in an existing codebase, and adding integrations, but it does not expose the testing templates as part of that workflow.
A developer who wants to add integration tests must know the template exists, run it from a terminal, add a project reference to the AppHost, update the generated `Projects` type, and add the project to the appropriate solution or workspace structure.
This is separate from #15575, which tracks showing a `DistributedApplicationTestingBuilder` AppHost in the Aspire pane while a test is already running.
### Describe the solution you'd like
Add an **Aspire: Add integration test project** command.
The command should:
- Discover C# AppHosts using the same workspace discovery used by the Aspire pane.
- Prompt for the target AppHost when more than one is available.
- Prompt for MSTest, NUnit, or xUnit, including supported framework-specific choices.
- Prompt for a project name and destination, validating output-directory conflicts before generation.
- Delegate project generation to the Aspire CLI and existing project templates.
- Add a project reference from the generated test project to the selected AppHost.
- Update the generated sample to use the selected AppHost's generated `Projects` type.
- Add the project to the applicable solution when one is present.
- Open the generated test in the editor and show a clear next step for running or debugging it.
If AppHost targeting or project-reference wiring belongs in the CLI template itself, add that CLI capability and keep the extension as a thin guided caller.
Completion criteria:
- The command is available when at least one compatible C# AppHost is discovered.
- MSTest, NUnit, and xUnit projects generated through the command restore and build without manual edits.
- The generated project contains the correct AppHost project reference and `DistributedApplicationTestingBuilder.CreateAsync` type.
- Multiple AppHosts and multiple workspace folders produce an explicit target picker.
- Destination conflicts are detected before template execution.
- Cancellation leaves no partial project behind.
- End-to-end coverage creates, builds, and runs a generated test project from the command.
### Additional context
The existing templates intentionally leave AppHost wiring as commented instructions. This issue is about making that wiring part of the editor-guided workflow while preserving the CLI and templates as the implementation source of truth.
Contributor guide
Research direction
Start with the VS Code extension's existing Aspire pane workspace discovery and guided commands, then inspect the Aspire CLI's aspire-mstest, aspire-nunit, and aspire-xunit templates. Trace how project references, generated Projects types, solutions, and workspace folders are handled. Done means the command validates destinations, supports target and framework selection, leaves no partial project on cancellation, and has end-to-end coverage for creating, building, and running the generated test project.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, vscode
- Domain
- testing, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100