Skip to content

feat(tools): add test statistics tool #102

Closed

Description

@CalvinAllen

Part of #95. Pairs with #101.

Expose Test Explorer's aggregate test counts as an MCP tool.

Proposed tool

test_stats — returns passed / failed / skipped / not-run counts for the current Test Explorer session.

Implementation notes

Public, supported API in Microsoft.VisualStudio.TestWindow.Interfaces.dll:

namespace Microsoft.VisualStudio.TestWindow.Extensibility;

public interface ITestExplorerStatsService
{
    TestExplorerStats TestExplorerStats { get; }
    bool IsTestExplorerStatsServiceRunning { get; }
    event EventHandler<TestExplorerStats> TestExplorerStatsChanged;
}

public struct TestExplorerStats
{
    public int PassedTestCount { get; }
    public int FailedTestCount { get; }
    public int SkippedTestCount { get; }
    public int NotRunTestCount { get; }
}

MEF-exported by Microsoft.VisualStudio.TestWindow.Data.TestExplorerStatsService (in Microsoft.VisualStudio.TestWindow.dll) with [Export(typeof(ITestExplorerStatsService))], so resolve it via:

var componentModel = await VS.GetServiceAsync<SComponentModel, IComponentModel>();
var stats = componentModel.GetService<ITestExplorerStatsService>();

Things to handle

  • Check IsTestExplorerStatsServiceRunning before reading. The service isn't live until Test Explorer has initialized. Return a clear "Test Explorer not initialized" result rather than reporting four zeros, which would be indistinguishable from a real empty run.
  • Consider having test_run_all / test_run from feat(tools): add test run and debug tools with completion tracking #101 fold the post-run stats into their own response, so the agent doesn't have to make a second call after every run.
  • TestExplorerStatsChanged is available if we ever want push-based reporting.

Scope note

This is counts only. There is no public API for the list of individual failed/un-run test names — see #95 for the details on why (internal types gated behind InternalsVisibleTo on Microsoft's strong-name key).

Assembly reference

Same as #101 — reference Microsoft.VisualStudio.TestWindow.Interfaces.dll from the VS install directory at 17.0.0.0 with CopyLocal=false.

Activity

  1. added
    enhancement
    on Sep 3, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions