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.0 → 17.0.0.0 |
yes |
| VS 2026 |
11.0.0.0-18.0.0.0 → 18.0.0.0 |
yes |
Public surface of Interfaces.dll is identical between VS 2022 17.14 and VS 2026 18.0 — verified.
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
test_run_alltest_debug_alltest_runtest_debugtest_cancelImplementation notes
Commands (via
DTE.ExecuteCommand, consistent with the existingVisualStudioServicepattern):TestExplorer.RunAllTestsTestExplorer.DebugAllTestsTestExplorer.RunAllTestsInContextTestExplorer.DebugAllTestsInContextThe
*InContextcommands 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 inVisualStudioServicefor this.Completion tracking
Don't return immediately. Import
IOperationStatefromMicrosoft.VisualStudio.TestWindow.Interfacesand await the terminal state off theTestOperationStatesenum:TestExecutionStarting/TestExecutionStartedTestExecutionFinishedTestExecutionCanceling/TestExecutionCancelAndFinishedDiscoveryStarting/DiscoveryFinishedThis 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.dllis not available on NuGet in a usable version (nuget.org only has 11.0.61030 from 2012). Reference it from the VS install directory withCopyLocal=false:Compile against the 17.0.0.0 assembly. VS ships
TestWindowProvideCodeBase.pkgdefwith binding redirects that cover both versions, so a single VSIX works across the[17.0,19.0)range:11.0.0.0-17.0.0.0→17.0.0.011.0.0.0-18.0.0.0→18.0.0.0Public surface of
Interfaces.dllis identical between VS 2022 17.14 and VS 2026 18.0 — verified.