Repository navigation
[Test Optimization] Skip VSTest-only arguments when dotnet test runs Microsoft.Testing.Platform - #9797
[Test Optimization] Skip VSTest-only arguments when dotnet test runs Microsoft.Testing.Platform#9797tonyredondo wants to merge 10 commits into
Conversation
…Microsoft.Testing.Platform
…se GetRandomFileName in tests
BenchmarksBenchmark execution time: 2026-11-26 19:53:53 Comparing candidate commit 37e8df0 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 18 metrics, 0 unstable metrics, 6 known flaky benchmarks, 137 flaky benchmarks without significant changes.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9797) and master. ✅ No regressions detected |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
Runner selection matches the inspected .NET 11 SDK within the documented compatibility limitations. The static review identified no reportable regression in collector argument handling.
🤖 Bits Code Review · Commit ef3b569
…t read the setting
There was a problem hiding this comment.
The PR skips incompatible VSTest coverage arguments for MTP and warns that per-test coverage is unavailable; the update fixes SDK-specific runner selection. One concern remains: blocking output reads defeat the new SDK probe’s timeout if it stalls, potentially hanging CI before tests launch; trailing-comma parsing remains a documented limitation.
🤖 Bits Code Review · Commit ad668d3
There was a problem hiding this comment.
More details
The SDK version gates preserve VSTest collector injection for older SDKs while allowing MTP runs to omit incompatible arguments. Static review of affected callers and comparison with SDK 11 runner selection produced no reportable finding.
🤖 Bits Code Review · Commit c7c0ada
Summary of changes
dd-trace ci run -- dotnet testno longer adds--test-adapter-path <dir> --collect DatadogCoveragewhendotnet testruns the Microsoft.Testing.Platform (MTP) command. It prints a warning that per-test code coverage isn't collected for that run instead. VSTest runs,dotnet vstestandvstest.consoleare unchanged.Reason for change
Relates to #9708. On the .NET 10 SDK and later, a repository can make
dotnet testrun MTP with"test": { "runner": "Microsoft.Testing.Platform" }inglobal.json. When code coverage is enabled, or the settings API turns on test skipping (which enables coverage too), the runner appends the VSTest-only options above. The MTP command rejects them, so the test run fails before any test runs. The only MTP awareness so far was the--coverage/--coverletcheck, which doesn't cover this opt-in.Per-test coverage under MTP needs its own change (the
DatadogCoveragedata collector is a VSTest extension that MTP never loads), so this PR only stops the failure.Implementation details
TestingPlatformRunnerDetectordecides whetherdotnet testruns MTP the same way the SDK does:DOTNET_TEST_RUNNERvalue (VSTestorMicrosoft.Testing.Platform, case-insensitive, trimmed) wins.test.runnerin the closestglobal.json, searched upward from the working directory, decides. Only the closestglobal.jsoncounts, even when it has notestsection. An unreadable file counts as VSTest.global.jsonor the environment say.dotnet --versionin the command's working directory, which honors theglobal.jsonSDK pin. It is only read when the environment orglobal.jsonselect MTP, so plain VSTest runs don't start an extra process.ProcessHelpers.RunCommandisn't used because it blocks reading the output before it checks its timeout; fixing the shared helper is left to a separate change, since its callers also run in .NET Framework test processes (see the discussion in the review).dotnet test --helpbuilds the projects of the working directory to list the test applications' options, and the in-processdotnetCLI hooks stop at SDK 9.CiUtilsskips the collector arguments (and the response-file rematerialization that only exists to place them before--) when the detector says MTP, and prints a warning to the console as well as the log. The--coverage/--coverletpath keeps precedence and is untouched.DOTNET_TEST_RUNNERis read through a newPlatformKeys.DotNetTestRunnerconstant.I checked each SDK rule above on Linux against
dotnet testwith SDK 8.0.134, 9.0.321, 10.0.115 and 11.0.100: closest-file-only, case-insensitive values,Global.json(capital G) ignored,DOTNET_TEST_RUNNERignored by SDK 10,test.runnerignored by SDK 8 and 9 (also with SDK 9'sDOTNET_CLI_TESTINGPLATFORM_ENABLE).Test coverage
TestingPlatformRunnerDetectorTestscoversglobal.jsoncontents (case, comments, other sections, non-string or missing runner, malformed JSON), parent-directory lookup, closest-file-only, environment-variable precedence, the SDK version gate (8, 9, 10, 11 and unreadable), that the SDK version isn't read when nothing selects MTP, and reading the version from a realdotnet --version.CiRunCommandTests.RemoteInternalCoverageDoesNotInjectVstestCollectorWhenDotnetTestRunsTestingPlatformgoes through the realci runentry point with test skipping enabled by the settings API. It checks that MTP gets no collector arguments and a warning, thatVSTeststill gets--collect DatadogCoverage, and thatdotnet vsteststill gets/Collect:DatadogCoverage.VSTestprecedence, the SDK version gate, the detection call inCiUtils, or the process-run timeout each makes at least one of these tests fail.CiRunCommandTests70 passed. The first version of the detector tests also passed on net11.0.global.json:ci run -- dotnet test --project T -c Release --no-buildwith coverage enabled exits 0, the 2 tests pass and the warning is printed. With the old behavior the same run exits 1.global.jsonselecting MTP but pinning SDK 8.0.134: the collector arguments are still added, as SDK 8 runs VSTest.Not run locally: Windows, macOS, .NET Framework, other target frameworks, a real backend.
Other details
Known limitations:
global.json. SDK 11 treats such a file as malformed and runs VSTest, while the runner still reads the runner value from it. SDK 10 fails to start with that file.TestingPlatformDotnetTestSupportintegration) accepts and ignores the collector arguments, so there's no per-test coverage and no warning. That isn't new with this change.