Skip to content

feat(tools): add test run and debug tools with completion tracking #101

Description

@CalvinAllen

Part of #95.

Add Test Explorer run/debug tools, with real completion tracking so the tools return meaningful results instead of firing and forgetting.

Proposed tools

Tool Behavior
test_run_all Run all tests in the solution
test_debug_all Debug all tests in the solution
test_run Run tests for a given class or method
test_debug Debug tests for a given class or method
test_cancel Cancel the in-flight run

Implementation notes

Commands (via DTE.ExecuteCommand, consistent with the existing VisualStudioService pattern):

  • TestExplorer.RunAllTests
  • TestExplorer.DebugAllTests
  • TestExplorer.RunAllTestsInContext
  • TestExplorer.DebugAllTestsInContext

The *InContext commands are caret-context based — the tool needs to open the target document and position the caret on the class/method before invoking. Worth reusing the existing navigation plumbing in VisualStudioService for this.

Completion tracking

Don't return immediately. Import IOperationState from Microsoft.VisualStudio.TestWindow.Interfaces and await the terminal state off the TestOperationStates enum:

  • TestExecutionStarting / TestExecutionStarted
  • TestExecutionFinished
  • TestExecutionCanceling / TestExecutionCancelAndFinished
  • DiscoveryStarting / DiscoveryFinished

This is what makes #96-style non-blocking contracts work properly here, and it's a prerequisite for the stats tool returning numbers that reflect the run that just happened.

Assembly reference

Microsoft.VisualStudio.TestWindow.Interfaces.dll is not available on NuGet in a usable version (nuget.org only has 11.0.61030 from 2012). Reference it from the VS install directory with CopyLocal=false:

$(DevEnvDir)CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll

Compile against the 17.0.0.0 assembly. VS ships TestWindowProvideCodeBase.pkgdef with binding redirects that cover both versions, so a single VSIX works across the [17.0,19.0) range:

Redirect codeBase
VS 2022 11.0.0.0-17.0.0.017.0.0.0 yes
VS 2026 11.0.0.0-18.0.0.018.0.0.0 yes

Public surface of Interfaces.dll is identical between VS 2022 17.14 and VS 2026 18.0 — verified.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions