Skip to content

[VS Code] Add a command to scaffold Aspire integration test projects #19409

Description

@adamint

Is there an existing issue for this?

  • 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<Projects...> 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions