VS2017 has the ability to profile applications. Is there also the ability to profile unit tests?
As per the other answer from @Wizou, the option to profile a unit test was missing for me in VS2019 professional.
Instead, what I did was this:
vstest.console.exe
telling it the specific dll to load and test to run, e.g. vstest.console.exe MyProject.Test.dll /Tests:TestFooBar
, and check that it worksNote: You'll probably find that most of the time is dominated by the test framework loading, static constructors, reflection and JITing things, and there's too much noise to determine which parts of your actual test are slow. To help, this dirty trick is quite effective:
[TestMethod]
public void TestFooBar()
{
for (int i = 0; i < 10000; i++) // extra iterations for profiling. Vary this number if 10k is too small
{
// your normal unit test which you'd only run once goes here
}
}
I am under VS Professional Edition and it is not available either.
It probably requires VS Enterprise Edition.
See also https://social.msdn.microsoft.com/Forums/en-US/49513731-23e6-4b65-acce-ed0a98e19b59/no-profile-test-option-in-context-menu-on-test-explorer-in-visual-studio-professional-2013?forum=vsunittest and https://visualstudio.microsoft.com/vs/compare/
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