How to profile unit tests in Visual Studio 2012?

Unit TestingProfilingVisual Studio-2012

Unit Testing Problem Overview


Is it possible to profile MSTest unit tests in Visual Studio 2012 Ultimate without using any external profiling tools?

Unit Testing Solutions


Solution 1 - Unit Testing

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.

Solution 2 - Unit Testing

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.

enter image description here

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.

Solution 3 - Unit Testing

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.

http://i.stack.imgur.com/1Wko1.png

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionalexeyView Question on Stackoverflow
Solution 1 - Unit TestingOleg SychView Answer on Stackoverflow
Solution 2 - Unit TestingCybermaxsView Answer on Stackoverflow
Solution 3 - Unit TestingMateen UlhaqView Answer on Stackoverflow