diff --git a/src/xunit.runner.visualstudio/Utility/DebuggerProcessLauncher.cs b/src/xunit.runner.visualstudio/Utility/DebuggerProcessLauncher.cs index b2eeda4..c623446 100644 --- a/src/xunit.runner.visualstudio/Utility/DebuggerProcessLauncher.cs +++ b/src/xunit.runner.visualstudio/Utility/DebuggerProcessLauncher.cs @@ -1,3 +1,5 @@ +using System.IO; +using System.Linq; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; using Xunit.v3; @@ -15,7 +17,25 @@ internal class DebuggerProcessLauncher(IFrameworkHandle2 frameworkHandle2) : if (testProcess is null) return null; - frameworkHandle2.AttachDebuggerToProcess(testProcess.ProcessID); + var waitForDebugger = false; + + if (responseFile is not null) + { + try + { + var switches = File.ReadAllLines(responseFile); + waitForDebugger = switches.Any(s => s.Equals("-waitForDebugger", System.StringComparison.OrdinalIgnoreCase)); + } + catch { } + } + + if (waitForDebugger) + try + { + frameworkHandle2.AttachDebuggerToProcess(testProcess.ProcessID); + } + catch { } + return testProcess; } }