Is it possible to profile MSTest unit tests in Visual Studio 2012 Ultimate without using any external profiling tools?
This feature was added back in the upcoming Visual Studio 2012 Quarterly Update 1. Right-click the test you want to profile in the Test Explorer and select "Profile Test" from the context menu.
In Visual Studio it was a really powerful feature !
As you, I can not find it in VS2012 (no references in MSDN or in blogs, ...)
Now, the only solution I have found for profiling Unit Test is to Attach the Profiler to a Process called vstest.executionengine.x86.exe (x86 for me but this could be different for 64 bits)
You can do this in the Tab "Performance Explorer" after a right click.
Once the profiler is starting, you can run as many tests as you want. Then stop profiling and you will see all details of this session.
There are 2 caveats with this technique :
for some reasons, the process is missing in the list. Maybe it stops when idle. Start just one test te see it.
You have to Attach the Profiler for every sessions. I don't find yet a way to script it.
Hope this will help you.
In Visual Studio 2015, follow the instructions Cybermaxs gives, but select TE.ProcessHost.Managed. Unfortunately, there appear to be two of them, so you must select the one with higher CPU usage.
With VS 2019/2022 you attach to the testhost process while running your tests. Just run your tests in debug, and stop execution on breakpoint, then you can find that process to attach.
Related
I have a solution that includes many tests, but I don't want to automatically run the tests every single time I build. Is there a way to do this in Visual Studio 2017?
I've checked Tools/Options. I've searched for this question in Stack Overflow, but don't find this question.
I've also checked the Solution Properties, but I don't see anything.
This question isn't a duplicate of this Stack Overflow question How to Prevent automatic test execution because it deals with the web portal and not Visual Studio 2017 IDE, itself.
Have you tried disabling "Run Tests After Build" from the Test Explorer window's toolbar? It should be the first button on the toolbar.
To open the Test Explorer window, go to Test -> Windows -> Test Explorer.
You first go to Test in the main menu, then go to Windows and then under the Windows, Run Tests After the Build button
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
When I'm updating my existing unit tests, Visual Studio code drops a status bar from the top letting me know that it could not correctly discover unit tests every time I save the file. This is expected since I'm actively typing so everything is not working python.
Have I configured something incorrectly? Is there some way to tell visual studio to chill out on the unit test discovery?
Of course, I can simply hit the "close" button, but this is extremely distracting.
Disable Live Unit Test running on the background.
Under Test->Test Settings-> uncheck 'Keep Test Execution Engine Running'. I am using VS 2017 & VS 2015.
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
Visual Studio 2012 added a "Run tests after build" button in the Unit Test Explorer, but it seems that option is not available in the Professional edition. In fact, my "Unit Test Explorer" is just called "Test Explorer", and doesn't have that button at all:
Are there any extensions which can replace this missing feature? Something that integrates with the existing test explorer UI would be ideal. (Free options are also preferred, since if I could convince my corporate overlords to shell out for VS Ultimate/Premium, this wouldn't be an issue anyway)
I remapped my F6 key to TestExplorer.RunAllTests instead of the default of Build.BuildSolution
Build.BuildSolution gets remapped to Ctrl-Shift-B when you do that.
It works well because now my F6 reflex RunAllTests saves any modified files, builds my solution and runs my unit tests.
The only thing I had to change is my window layout so that I can see the Test Explorer Window, that way I know if any tests failed.
Updating the answer with a link to a blog I wrote about this
The "Run Tests After Build" and "Profile Test" features are available in Premimum and Ultimate editions of Visual Studio 2012.
NCrunch is not free but it's well worth the money and superior to any and all test running features in Visual Studio, regardless of edition.
You could also have a look at http://www.continuoustests.com/ aka Mighty Moose.
It's not quite as slick as NCrunch, but it is free.