I'm trying to debug a failing unit test by putting a breakpoint at the beginning of the test method and choosing Debug Selected Tests in the Test Explorer. However, the test always runs (and fails) without hitting the breakpoint.
I've tried:
Cleaning and rebuilding the project
Restarting Visual Studio
This seems like a pretty basic case - I'm not attaching to a separate process, or doing anything fancy. Just a basic unit test inside VS2013. What else can I try to get the debugger to work correctly?
This did indeed turn out to be simple. I had forgotten that I told Visual Studio not to build the test project (Build - Configuration Manager - unchecked Build). I was trying to speed up my compile times, and it came back to bite me.
Long but simple story short, Build Configuration is another thing you can check if you strangely can't debug code you've placed breakpoints on in the IDE.
Related
I have some solutions with a bunch of projects and we have no unit test project in these solutions. However Visual Studio 2017 is still trying to discover unit tests and slowing down our process.
https://imgur.com/a/89Vt1P6
I looked at the runsettings xml file but there was nothing in there to disable it
https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file
any idea how we turn this unnecessary stuff off for some of our solutions?
Thanks
This was driving me crazy too. One day it just started running test discovery after every build, and switching my output pane to "Test" which is annoying.
How I fixed it in VS 2015 (may be the same for 2017),
disable (uncheck) this setting:
Test menu --> Test Settings --> Keep Test Execution Engine Running
I know there are several VS keyboard shortcuts for running unit tests, but the one I really can't find and would like is to be able to run the last executed test in debug mode.
Ctrl+R, L will repeat the last run, but not in debug mode.
If you are debugging a test, and it changes context to the code you are actually running, and then you stop the test, is there a way to start that test in debug mode again using just the keyboard?
I wanted the same thing.
Based on the technique found in the following post
Visual Studio 2012 debug tests keyboard shortcut
I searched for TestExplorer.DebugSelectedTests and assigned a shortcut key to it.
At least in VS2015 (and hopefully in VS 2013) even while debugging changes context to the code you are actually running. The test remains selected in the test explorer window. So, you can run your shortcut key combo and the test will debug again.
Hope this solves the problem for you too.
I know this question was for Visual Studio 2013, but got google go me here.
In Visual Studio 2019 is a shortcut for that Ctrl+R,D:
If you are using ReSharper, you can use Ctrl+U, D to rerun a test in Debug mode.
https://www.jetbrains.com/resharper/features/unit_testing.html
could you tell me why this happens when I simply press F5 in order to start debugging? VS is freshly installed and can't run hello world program :(
I checked for c# console application and that module works, only problem is when choosing C++
here is the screenshot..
http://s50.radikal.ru/i129/1310/c5/ee67bc538bec.png
First, i would recommend to Clean the project and choose Rebuild.
If the problem is still there, you need to check the exe location, and try to execute it manually.
I would say that the error is likely to come from some changes you did (project configuration) that require you to clean the solution, but it is just a mere guess.
I was working on a project when all of a sudden VS stopped recompiling my project each time I debugged (mid way through working... I never changed anything). So it keeps running the same old build over and over.
I don't want to have to "clean build" each time, and I've followed the instructions here (Visual Studio 2010 doesn't rebuild changed code unless I manually select "Rebuild"). Surprisingly, they were already set (prompt to build when project outdated, build is checked under configuration manager).
However, it still never prompts me (except for after clean), and it's getting really frustrating. I'm using VS c++ if it helps.
I just had the same issue. This might solve your problem:
Tools->Options->Project and Solution->Build and Run.
There is an option what to do for "On run, when projects are out of date". Set this to "always create". This will mean that if you compile a project which depends on another project in your project folder, then the other project is compiled first, just as you want.
In my case, this option was set but then set to something else after a crash of VS2010.
I'm using Visual Studio 2010 C++ with Google test. I have a post-build event on my test project to run the test project. This works and the google test test results are displayed in the visual studio output window. However, now I'd like to set a debug breakpoint to step through a test. When I set a break point in either my test code or in the code it calls nothing happens.
How can I set a breakpoint with google test? Or probably more accurately, how can I get it to trigger the debugger?
I guess you have a separate project that builds the test. You should just run it under the debugger.