Skip to content

Commit 1ad595b

Browse files
authored
How to debug integration tests (#6466)
1 parent 475da54 commit 1ad595b

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

docs/debugging.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
For basics on how to set-up your repo and how to build the product, refer to the [contributing guide](../CONTRIBUTING.md).
44

5+
## Debugging integration tests
6+
7+
The test projects Dotnet.Integration.Tests, MSBuild.Integration.Tests and NuGet.CommandLine.FuncTests all run NuGet in child processes.
8+
This means you can't normally put breakpoints in the product code, since that code won't run in the test host.
9+
However, there is a [Microsoft Child Process Debugging Power Tool](https://marketplace.visualstudio.com/items?itemName=vsdbgplat.MicrosoftChildProcessDebuggingPowerTool2022), which can automatically attach to child processes when debugging in Visual Studio.
10+
11+
As the extension says:
12+
13+
> The power tool requires a native debugger. This means if you are debugging .NET code, you must choose to enable mixed mode debugging (so managed and native)
14+
15+
It's the same to do this for test projects, or console apps, in the project property's debug settings.
16+
17+
![Enable native code debugging](./images/enable-mixed-mode-debugging.png)
18+
19+
After installing the child process debugging power tool, remember to go to its settings and enable child process debugging.
20+
21+
![Enable child process debugger in extension settings](./images/enable-child-process-debugging.png)
22+
23+
Now, when debugging tests, any breakpoints in product code should be hit.
24+
If your breakpoints are not stopping the debugger, you can check if child processes are being attached by opening the debugger Processes window.
25+
If the debugger is successfully attaching to the child process, you will see it appear and disappear in this list.
26+
27+
![alt text](./images/vs-debugger-processes-list.png)
28+
29+
If you don't see the process appear, then you need to check the extension's settings and check that mixed mode (native code) debugging is enabled.
30+
If the child process does appear, it probably means that your breakpoints are in code that is not getting run.
31+
532
## Debugging and testing NuGet.exe (NuGet.Commandline)
633

734
Given that it is a .NET Framework based x86 console application, NuGet.exe is straightforward to debug.
@@ -23,7 +50,7 @@ Testing the NuGet Visual Studio functionality is equally as easy as testing NuGe
2350
The start-up project is [NuGet.VisualStudio.Client](../src/NuGet.Clients/NuGet.VisualStudio.Client/NuGet.VisualStudio.Client.csproj). Starting this project will build the VSIX, then install that VSIX onto and launch your [experimental instance](https://docs.microsoft.com/en-us/visualstudio/extensibility/the-experimental-instance) of Visual Studio.
2451

2552
> Note: NuGet's integration into Visual Studio depends on Visual Studio components. When testing this integration it is important that the version of NuGet being tested and the Visual Studio instance are compatible. The [release notes](https://learn.microsoft.com/nuget/release-notes/) contain the exact mapping, where the minor version of NuGet matches the minor version of Visual Studio, example 17.12 of Visual Studio matches 6.12 of NuGet.
26-
Testing NuGet 6.12 on top of 17.8 for example is not guaranteed to work.
53+
Testing NuGet 6.12 on top of 17.8 for example is not guaranteed to work.
2754
Only testing 6.12 on top of 17.12 is expected to consistently work.
2855

2956
### Testing the build of NuGet in Visual Studio
50.8 KB
Loading
3.14 KB
Loading
6.32 KB
Loading

0 commit comments

Comments
 (0)