Document debugging integration tests with AttachVS by Copilot · Pull Request #15452 · microsoft/vstest (original) (raw)
Integration tests spawn vstest.console and testhost as child processes, making them hard to debug. The DebugInfo properties on test data source attributes existed but AttachVS.exe wasn't automatically resolved, requiring manual setup.
Changes
Fix: Auto-resolve AttachVS.exe path
- Added
ProjectReferencetoAttachVS.csprojinMicrosoft.TestPlatform.TestUtilities.csprojsoAttachVS.exeis built into the test output directory AddDebugEnvironmentVariables()now automatically setsVSTEST_DEBUG_ATTACHVS_PATHto the co-locatedAttachVS.exewheneverDebugInfois active — no manual path configuration needed
Docs: Debugging integration tests (docs/contribute.md)
Added a new section covering how to attach VS to child processes spawned by integration tests:
[TestMethod] [NetCoreRunner(AcceptanceTestBase.NET9, DebugVSTestConsole = true)] public void MyTest(RunnerInfo runnerInfo) { ... }
| Property | Process debugged | Env var set |
|---|---|---|
| DebugVSTestConsole = true | vstest.console | VSTEST_RUNNER_DEBUG_ATTACHVS=1 |
| DebugTestHost = true | testhost | VSTEST_HOST_DEBUG_ATTACHVS=1 |
| DebugDataCollector = true | data collector | VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS=1 |
| DebugStopAtEntrypoint = true | (keeps entry-point BP) | suppresses VSTEST_DEBUG_NOBP=1 |
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
pdfvsblobprodcus380.vsblob.vsassets.io- Triggering command:
/home/REDACTED/work/vstest/vstest/.dotnet/dotnet /home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/11.0.0-beta.26127.1.txt(dns block) - Triggering command:
.dotnet/dotnet .dotnet/dotnet build test/Microsoft.TestPlatform.TestUtilities/Microsoft.TestPlatform.TestUtilities.csproj --no-restore -f net9.0 et7/11.0.100-preview.1.26104.118/ kload.emscripten.net7/11.0.100-preview.1.26104.118/(dns block)
- Triggering command:
pe4vsblobprodcus351.vsblob.vsassets.io- Triggering command:
.dotnet/dotnet .dotnet/dotnet build test/Microsoft.TestPlatform.TestUtilities/Microsoft.TestPlatform.TestUtilities.csproj --no-restore -f net9.0 et7/11.0.100-preview.1.26104.118/ kload.emscripten.net7/11.0.100-preview.1.26104.118/(dns block)
- Triggering command:
If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.