I have a C# project in Visual Studio 2017 Professional. It has some unit tests: methods declared with [Test]
which display a little green tick icon in the editor, where I can right-click and 'Run' or 'Debug' the test. When I do so, a window opens with all tests in the solution and I can click a green 'play' triangle to run them all.
I can also run my program under the profiler starting from Debug -> Performance Profiler.
So far so good. Now, how do I run a unit test under the profiler?
When I first asked this question I looked for profiling unit tests and saw it was a feature in Visual Studio Professional. But in fact, I'm not using VS's own unit testing support, but rather NUnit, driven by Resharper. Sorry to throw everyone off the scent.
I'm using Visual Studio Enterprise 2017 , so I cannot check, whether this works in Professional , or not.
Ctrl + Q
, then type Test Explorer
and hit Enter
I must note, that I'm using xunit and autofixture , and I haven't seen this feature working. See this issue , why I haven't.
Hence, based on the answer of Jeremy Liberman , I was able to work around using the steps below:
xunit.runner.console
NuGet package to the test project c:\\<...>\\src\\packages\\xunit.runner.console.2.4.0\\tools\\net472\\xunit.console.exe
(fit this to your environment) <Product>.Tests\\bin\\Debug\\<Product>.Tests.dll
c:\\<...>\\src\\
(the root of the Solution ) Note, that this profiles all of the tests in the test assembly. You can choose, which tests you want to run by providing more Command-line arguments to xunit.runner.console
. To learn more about the console runner options, run the console runner with no command line options.
如果您可以在断点处调试和停止,则还应该能够根据此页面获取CPU和内存使用情况,因为您在调试时启用了诊断工具 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.