Skip to content

Comments

Fix test runner detection to search current directory when no paths provided#331

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-test-runner-telemetry
Draft

Fix test runner detection to search current directory when no paths provided#331
Copilot wants to merge 3 commits intomainfrom
copilot/fix-test-runner-telemetry

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Test runner detection defaulted to VSTest when neither workingDirectory nor project parameters were specified, failing to find global.json in the current directory or parent directories. This affected Aspire project layouts where global.json sits at the repository root.

// global.json at repo root
{
  "test": { "runner": "Microsoft.Testing.Platform" }
}
// Previously: always reported vstest/default
await DotnetProject(action: Test, testRunner: Auto);

// Now: correctly detects MTP from global.json in current/parent dirs

Changes

TestRunnerDetector.cs

  • Fall back to Directory.GetCurrentDirectory() when both workingDirectory and projectPath are null
  • Maintains VSTest default if current directory access fails

Tests

  • Added coverage for current directory fallback
  • Added scenarios: project directory, parent directory (Aspire layout), solution files
  • Updated existing test for new fallback behavior

Detection now works correctly when:

  • Running from repo root without parameters
  • Project has global.json in parent directory
  • Testing via solution file with root-level global.json
Original prompt

This section details on the original issue you should resolve

<issue_title>dotnet_project Test: selectedTestRunner / runner telemetry should match the actual runner used (MTP projects currently report VSTest)</issue_title>
<issue_description>#### Summary

In a mixed test solution containing an MTP-enabled xUnit v3 test project (generated via Aspire templates), MCP dotnet_project Test machine-readable metadata reported:

  • selectedTestRunner: vstest
  • selectionSource: default

The console output also printed VSTest version ... even when executing the MTP project.

Important nuance: setting these MSBuild properties does not appear to switch dotnet test to MTP by itself:

  • <UseMicrosoftTestingPlatformRunner> affects dotnet run, not dotnet test.
  • <TestingPlatformDotnetTestSupport> makes the project compatible with MTP but does not select MTP as the default runner.

In practice, switching dotnet test to MTP requires global.json opt-in:

{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}

This makes it hard for clients to understand whether MTP was used, and prevents reliable orchestration/UX for mixed runner repos.

Repro steps

  1. Create an Aspire test project with MTP enabled (example: dotnet new aspire-xunit --xunit-version v3mtp), which sets:
    • <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
    • <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
  2. (Optional) Add global.json with { "test": { "runner": "Microsoft.Testing.Platform" } } either at repo root or scoped to the test subtree.
  3. Run MCP dotnet_project Test on the solution.

Actual behavior

  • MCP returns selectedTestRunner: vstest (even when the csproj is MTP-capable).

Expected behavior

  • MCP should detect and report MTP when global.json opt-in applies (or document if/why VSTest still appears in output even when MTP is active).
  • Machine-readable output should include enough telemetry to disambiguate:
    • selectedTestRunner
    • selectionSource
    • (optional) runnerEvidence (e.g., discovered global.json runner setting, csproj properties, or CLI output markers).

Environment

  • Windows
  • .NET SDK 10.0.102
  • Aspire.ProjectTemplates 13.1.0
    </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 10, 2026 03:17
Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix runner telemetry for MTP projects in dotnet_project Test Fix test runner detection to search current directory when no paths provided Feb 10, 2026
Copilot AI requested a review from jongalloway February 10, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet_project Test: selectedTestRunner / runner telemetry should match the actual runner used (MTP projects currently report VSTest)

2 participants