Repository navigation
Consolidate local test execution - #55787
Conversation
|
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. |
There was a problem hiding this comment.
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.csas the centralized local runner, including framework selection, diagnostics directory creation, and rerun guidance. - Update contributor docs and agent skills to use
run-tests/RunTests.csinstead of bespokedotnet 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 --frameworkis passed into the initialmsbuild -getPropertyevaluation (viaEvaluateProjectProperties), which can overrideTargetFrameworkfor 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.
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
dcb0d37 to
a3751a7
Compare
| - 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`. |
There was a problem hiding this comment.
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.
| 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. |
There was a problem hiding this comment.
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".
|
|
||
| 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. |
There was a problem hiding this comment.
Let's be consistent about how we tell agents to invoke skills. I would word it like:
| 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.
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
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 existingtargeted-testworkflow 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-testworkflow with a generalrun-testsentry point backed byscripts/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.