Skip to content

Consolidate local test execution - #55787

Merged
mthalman merged 6 commits into
dotnet:mainfrom
mthalman:mthalman-evaluate-agent-failure-diagnosis
Aug 26, 2026
Merged

mthalman merged 6 commits into
dotnet:mainfrom
mthalman:mthalman-evaluate-agent-failure-diagnosis

Conversation

@mthalman

Copy link
Copy Markdown
Member

Problem

Local test execution was documented through several different command shapes with different diagnostic guarantees. The developer guide used raw dotnet test, while specialized workflows directly invoked built Microsoft.Testing.Platform applications. The existing targeted-test workflow retained diagnostics, but it was framed as an agent-only targeted-test helper rather than the repository’s standard contributor entry point.

As a result, there was no single local testing contract that consistently built the selected test project, chose the appropriate framework and test-application launcher, and returned stable TRX and MSBuild binlog paths. The required Microsoft.Testing.Platform, multi-targeting, and .NET Framework behavior was implemented in other repository infrastructure but was not available through one reusable local command.

Fix

This change replaces the narrow targeted-test workflow with a general run-tests entry point backed by scripts/RunTests.cs.

The runner evaluates the selected project rather than guessing its test platform. It selects the appropriate target framework, builds that framework incrementally with an MSBuild binlog, and invokes the resulting Microsoft.Testing.Platform application correctly. Multi-targeted projects default to the repository’s current SDK framework, while callers can explicitly select another framework, including .NET Framework on Windows.

Every run receives a unique diagnostics directory. The runner reports the build binlog and, when supported by the project, the TRX. Failures also include the failed test names and a portable command that reruns the same project, framework, configuration, and filter through RunTests.cs.

Repository instructions, specialized agent workflows, and contributor documentation now use this entry point instead of constructing test commands independently. Characterization tests cover single-target and multi-target execution, .NET Framework applications, argument validation, diagnostics, and portable reruns.

Copilot AI lite review requested due to automatic review settings August 14, 2026 18:00
@mthalman
mthalman requested a review from lbussell as a code owner August 14, 2026 18:00
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request consolidates local test execution guidance and workflows around a single contributor-facing entry point (scripts/RunTests.cs) that builds the selected test project incrementally and preserves diagnostics (binlog/TRX) while selecting the appropriate test-application launcher.

Changes:

  • Add/expand scripts/RunTests.cs as the centralized local runner, including framework selection, diagnostics directory creation, and rerun guidance.
  • Update contributor docs and agent skills to use run-tests/RunTests.cs instead of bespoke dotnet test / legacy targeted-test shapes.
  • Add characterization tests validating help/arg validation/framework selection/diagnostic output for the new runner.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/RunTests.cs Implements the consolidated local test runner (MSBuild evaluation, build+run flow, diagnostics, rerun guidance).
test/Microsoft.NET.Infrastructure.Tests/RunTestsScriptTests.cs Adds characterization coverage for RunTests.cs behavior and output contracts.
test/ConditionalTests.props Updates documentation to reflect the new run-tests skill consuming conditional test scopes.
test/AGENTS.md Shifts local test execution guidance to run-tests as the standard entry point.
documentation/project-docs/pr-test-filtering.md Updates references from prior runner/skill to run-tests.
documentation/project-docs/developer-guide.md Updates the contributor developer guide to use scripts/RunTests.cs for local CLI test runs.
.github/skills/run-tests/SKILL.md Documents the standardized runner usage, diagnostics expectations, and redist-check guidance.
.github/skills/migrate-xunit-to-mstest/SKILL.md Updates migration verification step to use run-tests.
.github/skills/incremental-test/SKILL.md Updates incremental test instructions to use run-tests.
.github/skills/add-net-analyzer/SKILL.md Updates analyzer workflow test execution to use run-tests (with --skip-redist-check).
.github/skills/add-dotnet-aot-command/SKILL.md Updates AOT command workflow to use run-tests for managed iteration guidance.
.github/copilot-instructions.md Updates repo-wide agent guidance to standardize on run-tests.
.github/agents/static-web-assets-agent.agent.md Updates the SWA agent playbook to use RunTests.cs rather than hand-rolled build/test commands.
Suppressed comments (2)

scripts/RunTests.cs:366

  • When TRX reporting is not enabled for a project, the runner explicitly warns that it will continue without a TRX. If the test run then fails, the current error message claims the failure happened before results were written, which is misleading (the TRX may simply be disabled).
    scripts/RunTests.cs:421
  • --framework is passed into the initial msbuild -getProperty evaluation (via EvaluateProjectProperties), which can override TargetFramework for single-target projects and prevents reliably validating the requested TFM against the project’s declared TFMs. This can lead to confusing behavior (building/running an unintended TFM) instead of a clear validation error.

mthalman and others added 3 commits August 19, 2026 08:57
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 184c5acd-9937-4b90-8ae1-44d9ee765955
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 184c5acd-9937-4b90-8ae1-44d9ee765955
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 184c5acd-9937-4b90-8ae1-44d9ee765955
@mthalman
mthalman force-pushed the mthalman-evaluate-agent-failure-diagnosis branch from dcb0d37 to a3751a7 Compare August 19, 2026 14:11
Comment thread .github/copilot-instructions.md Outdated
Comment on lines 154 to 167
- Run tests through the `run-tests` skill — prefer a single test project, class, or method
(see the [Testing](#testing) section). `build.cmd -test` /
`./build.sh --test` runs the **entire** suite, which is very large and takes a long time;
avoid running the full suite for routine local or agent work.
- Release build: `build.cmd -c Release`.
- Run a single test project after a full build:
`./.dotnet/dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter "FullyQualifiedName~TestName"`.
See the [Testing](#testing) section for assembly filtering and more examples.
- Run a single test through the centralized runner:
`./.dotnet/dotnet scripts/RunTests.cs -- --project test/dotnet.Tests/dotnet.Tests.csproj --filter "FullyQualifiedName~TestName"`.
See the [Testing](#testing) section for project selection and more examples.
- Validate changes locally using the SDK you built at
`artifacts/bin/redist/<configuration>/dotnet` (`Debug` by default).
- Use the `targeted-test` skill to select projects from the shared
- Use the `run-tests` skill to select projects from the shared
`test/ConditionalTests.props` scopes when available and retain detailed failure output,
a TRX, and a binlog. For fast inner-loop runs of `dotnet.Tests` without a full rebuild,
use `incremental-test`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's because I don't work in this repo very much, but I don't see why we need 3 separate bullets about running tests, intertwined between build instructions.
Agents will most likely invoke the run-tests skill, therefore we should just tell it to do that and leave the details out of this document since they aren't always required.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e4e5041

Comment thread .github/skills/run-tests/SKILL.md Outdated
entry point. REQUIRED whenever an agent will select, run, or rerun local dotnet/sdk
tests, including a project, class, method, targeted test, focused test, smallest
relevant test, or completed-change validation. NEVER invoke when the user says not to
run tests yet. DO NOT USE for the complete repository test suite.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, is there something else agents should do for complete repository test suites?
IMO we probably shouldn't have this qualifier and instead we can provide specific guidance inside the skill. Even if the guidance is "please don't try to run all of the tests".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9a77209


1. `dotnet build` -- must succeed with zero errors. Address remaining errors using the mapping reference.
2. `dotnet test` -- run with the **same** filter/runner combination as before migration.
2. Use **run-tests** with the same project, framework, and filter as the Step 1.7 baseline.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be consistent about how we tell agents to invoke skills. I would word it like:

Suggested change
2. Use **run-tests** with the same project, framework, and filter as the Step 1.7 baseline.
2. Invoke the `run-tests` skill to test the same project, framework, and filter as the Step 1.7 baseline.

Applies to other references to skills from skills in this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b872da2

mthalman and others added 3 commits August 20, 2026 09:45
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 184c5acd-9937-4b90-8ae1-44d9ee765955
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 184c5acd-9937-4b90-8ae1-44d9ee765955
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 184c5acd-9937-4b90-8ae1-44d9ee765955
@mthalman
mthalman requested a review from lbussell August 20, 2026 15:04
@mthalman
mthalman enabled auto-merge (squash) August 20, 2026 15:34
@mthalman
mthalman disabled auto-merge August 26, 2026 15:19
@mthalman
mthalman merged commit c07b54b into dotnet:main Aug 26, 2026
28 of 31 checks passed
@mthalman
mthalman deleted the mthalman-evaluate-agent-failure-diagnosis branch August 26, 2026 15:46
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 27, 2026

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — b872da2a Deployed Aug 26, 2026 by mthalman via pre_activation #1071
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants