-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing: Need to step-in-to and debug the test adapter discovery process #7419
Comments
@dotnet/vstest can you please take a look? |
This instruction works for vstest.console.exe, dotnet test and dotnet vstest. Debug test platform componentsThe runner and test host processes support waiting for debugger attach. You can
For test host process (
|
Note that adapters load in the testhost, so just |
Timeout is not configurable at the moment. We should be able to print out process id, will track this for upcoming release. If you're attaching from VS, observation is that the top most |
Putting out a PID would be good next step. You can see how bad the instructions are: We have to rely on Process Explorer. That said, for me, opening the Attach to Process dialog takes 5-10 sec for it to load.... it's super slow to keep doing that in a tight loop. It would be much better if VS could auto-attach to child dotnet processes and/or do something like the "Debug selected test" function does where it attaches to the correct instance. We just need that for discovery mode somehow. |
@onovotny Its not what I would like, but this by far the best solution that I have found: Microsoft Child Process Debugging Power ToolInstall the Microsoft Child Process Debugging Power Tool which was created by an employee at Microsoft. This allows you to configure the Visual Studio debugger to attach to child processes (which is how vstest.console.exe executes tests) Once installed, open your solution and enable child process debugging:
If you choose to persist the settings, your settings file might look something like this: <?xml version="1.0" encoding="utf-8"?>
<!-- EngineFilter Guid was found here: https://blogs.msdn.microsoft.com/martintracy/2006/05/16/debug-engine-guids/ -->
<ChildProcessDebuggingSettings IsEnabled="true" xmlns="http://schemas.microsoft.com/vstudio/ChildProcessDebuggingSettings/2014">
<DefaultRule Attach="false" />
<Rule IsEnabled="true" ProcessName="TE.ProcessHost.Managed.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
<Rule IsEnabled="true" ProcessName="vstest.discoveryengine.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
<Rule IsEnabled="true" ProcessName="vstest.discoveryengine.x86.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
<Rule IsEnabled="true" ProcessName="vstest.executionengine.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
<Rule IsEnabled="true" ProcessName="vstest.executionengine.x86.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
</ChildProcessDebuggingSettings> Once this has been setup, you then just need to make sure your project is setup to debug with vstest.console.exe. The key point here is making sure that you enable native/unmanaged debugging, otherwise the child process debugging tool wont work. New csproj SystemEdit or create a {
"profiles": {
"DebugTestAdapter": {
"commandName": "Executable",
"executablePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe",
"commandLineArgs": "Tests.dll --ListTests --TestAdapterPath:.",
"workingDirectory": "C:\\Projects\\TestAdapter\\Tests\\bin\\Debug\\net46"
}
}
} Modify your csproj file to contain the following property, which enabled native debugging: <PropertyGroup>
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup> Old csproj SystemIn the debug properties page of your project, set the following settings: Start external program:
Command line arguments:
Working directory:
Enable native code debugging: |
@codito Do VSTEST_RUNNER_DEBUG and VSTEST_HOST_DEBUG also work for version 14.0 of vstest.console.exe? I am trying it out, but it doesn't wait for the debugger to be attached. |
@sandeepiiit no, it is only supported in newer versions of vstest.console.
For older versions, try Debugger.Launch if you have the source code or
dnspy if source code is not available.
…On Thu 22 Mar, 2018, 5:29 AM sandeepiiit, ***@***.***> wrote:
@codito <https://github.com/codito> Do VSTEST_RUNNER_DEBUG and
VSTEST_HOST_DEBUG also work for version 14.0 of vstest.console.exe? I am
trying it out, but it doesn't wait for the debugger to be attached.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/dotnet/cli/issues/5136#issuecomment-375134559>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABwXnttyrotARE-TA-FdYQIFl0xEByAks5tgulxgaJpZM4LUjax>
.
|
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label. |
This issue will now be closed since it has been labeled 'stale' without activity for 30 days. |
While working on getting xUnit working better on the new test platform, I've been struggling with code that executes at discovery time.
I'm sure that the issues themselves would be easy to spot/fix once in a debugger, but that's the real issue -- there doesn't seem to be any way of getting a debugger to attach to the correct dotnet instance that's loading the adapter in discovery mode.
If you run
dotnet vstest
path\to\test.dll, it appears so spawn off another dotnet instance.Things that don't help -- the Child Process Debugging tool requires that win32 debugging be enabled. It also does not seem to currently support CoreCLR as one of the debug engines you can start a child on.
What I really need: A way to debug the test adapter code in discovery mode. Debugging test execution mode is a little easier because you can "debug selected test" and VS does attach to the right process and we can set breakpoints in our adapter code before it gets to the test.
The text was updated successfully, but these errors were encountered: