Browse documentation

trace_run_tests

[solution]

Runs .NET tests and stores failures, output, and available TRX artifacts.

Before you use this tool

Executes test runners with your local permissions. Test runs can change workspace files and contact package sources. Check the workspace and runner policy. Supports dotnet test, dotnet vstest, and policy-validated native vstest.console. Use filters for expensive test suites.

Try it locally in the GliderTrace playground

Parameters

NameTypeRequiredDescription
targetPathstringNoOptional solution, project, or directory path under the workspace root. Defaults to the workspace root. Not valid with runner 'vstest' or 'vstest-console'.
configurationstringNoBuild configuration passed to dotnet test. Defaults to Release. Not valid with runner 'vstest' or 'vstest-console'.
filterstringNoOptional dotnet test filter expression. With a VSTest runner, it is applied as TestCaseFilter.
verbositystringNodotnet test verbosity: 'quiet', 'minimal', 'normal', 'detailed', or 'diagnostic'. Defaults to minimal. Not valid with runner 'vstest' or 'vstest-console'.
noRestorebooleanNoPass --no-restore to dotnet test. Defaults to false so fresh workspaces can restore normally. Default: false
collectBlamebooleanNoCollect blame sequence artifacts when supported. Defaults to true. Default: true
rerunFailednumberNoNumber of times to rerun safely identified failed tests. Defaults to 0. A matching structured pass establishes a flaky candidate. Default: 0
runnerstringNoTest runner: 'auto' (default, dotnet test with mode detection), 'dotnet-test', or 'vstest' (dotnet vstest against prebuilt assemblies). From GliderTrace 1.1.0: 'vstest-console' uses native VSTest and requires its executable policy. 'nunit-console' and 'msbuild-vstest' are reserved for a future release.
assembliesjsonNoPrebuilt test assembly paths under a configured workspace root. Requires runner 'vstest' or 'vstest-console'.
testsjsonNoExact FullyQualifiedName test names, run through a VSTest TestCaseFilter so each name matches exactly. Requires runner 'vstest' or 'vstest-console'; cannot be combined with filter or testCaseFilter.
testCaseFilterstringNoVSTest TestCaseFilter expression for trait/category selection. Requires runner 'vstest' or 'vstest-console'.
testAdapterPathstringNoDirectory containing test adapters, mapped to VSTest TestAdapterPath. Requires runner 'vstest' or 'vstest-console'.
platformstringNoTarget platform architecture for VSTest: 'x86', 'x64', or 'ARM'. Requires runner 'vstest' or 'vstest-console'.
frameworkstringNoTarget framework moniker for VSTest, for example Framework48. Requires runner 'vstest' or 'vstest-console'.
vstestConsolePathstringNoNative VSTest executable path. Requires runner vstest-console.
runSettingsPathstringNoWorkspace-scoped VSTest settings. Collectors, custom loggers, and dump capture are rejected.
timeoutMsnumberNoTest timeout in milliseconds. A timeout stores a timeout status.
labelstringNoOptional short label for the stored session, for example nightly-baseline. Use it to find the session again with trace_list_sessions. Maximum 128 characters.

Examples

Replace sample paths and symbol keys with values from your workspace.

Run tests for the current workspace

Arguments
{}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "trace_run_tests",
    "arguments": {}
  }
}

Run a prebuilt legacy test assembly through vstest

Arguments
{
  "runner": "vstest",
  "assemblies": [
    "Tests/bin/Debug/Sample.UnitTests.dll"
  ]
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "trace_run_tests",
    "arguments": {
      "runner": "vstest",
      "assemblies": [
        "Tests/bin/Debug/Sample.UnitTests.dll"
      ]
    }
  }
}

Response Notes

Returns a test session id, result summary, TRX artifacts, stdout/stderr references, failure evidence, and rerun metadata. The summary adds knownFlakyFailures. flakyAnnotations carries the cross-session flake history for each failure the ledger has seen before. Each annotation lists failingSessions, flakyCandidateSessions, knownFlaky, firstSeen, and lastSeen. An annotation tags a failure; it never hides one.

From GliderTrace 1.0.0: Read testCountStatus: exact, partial, or unknown. testCountSource is trx or none; testCountReason explains uncertainty. testCountScope identifies the attempt. Counts remain numeric strings when known and use unknown otherwise. This also applies to initialFailedTests and finalFailedTests.

The reportedTotalTests, reportedPassedTests, reportedFailedTests, and reportedSkippedTests fields give available report subtotals. reportedTestCountScope is structured-reports. A report subtotal does not prove coverage of every requested target. An exit code of zero does not establish an exact test total.

Only a matching structured pass clears a failed test and establishes a flaky candidate. A skipped test or missing report leaves the failure unresolved. Capture coverage retains gaps from earlier attempts, even when a later attempt passes.

GliderTrace 1.0.0 returns compact JSON for every tool. Result fields appear beside success; there is no response-format parameter. success describes the tool call. Check the process or session status and exitCode separately. Scalar results and fields that conflict with reserved names appear under result.

To migrate an envelope consumer, read response.sessionId instead of response.data.sessionId. Stored sessions and exported files keep their formats. --max-response-chars limits response text to 60,000 UTF-16 characters by default. Use 0 to disable it, or at least 1,000. This limit counts text characters, not transport bytes or tokens.

outputLimit.truncated marks omitted response detail. It does not change capture completeness. Use the returned next tool and arguments when available. Do not repeat a command or feedback submission to recover omitted output. For event pages, keep the filters and cursor while reducing limit.

For session details, set includeArtifacts and includeTopFindings to false to reduce output. Check error, actionable meta, warnings, and coverage before drawing conclusions. Internal diagnostics stay in local server logs.