I am having difficulty debugging C++ x64 unit tests in Visual Studio 2012/13.
My unit test project builds perfectly, for both Win32 and x64, but when debugging a test the symbols are loaded but the breakpoints set are skipped completely and the program never pauses, much like what happens if you just run the test.
If I build the unit test project for Win32, the breakpoints are hit and I can debug as usual.
Are there any special settings for debugging unit tests in x64? The properties were copied from the default Win32 settings for the project, and all win32-specific options were removed. Is this the correct idea for configuring a unit test project?
To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.
From the Visual Studio menu, choose Test, then choose Processor Architecture for AnyCPU projects. Choose x64 to run the tests as a 64-bit process.
From the BUILD menu in Visual Studio, select Configuration Manager. From the Active solution platform drop-down list, select New. The New Solution Platform dialog displays. In the Type or select new platform combination box, select x64.
Visual Studio 2022 on Windows is now a 64-bit application.
You have to set the Test runner's default processor architecture to x64. You can find this in Test | Test Settings | Default Processor Architecture | x64.
You can also create a test settings file with this setting in it.
Taken from Configuring Unit Tests by using a .runsettings File
You want to change the TargetPlatform
flag as noted below.
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<ResultsDirectory>.\TestResults</ResultsDirectory>
<TargetPlatform>x86</TargetPlatform>
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
</RunConfiguration>
<!-- more stuff -->
</RunSettings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With