Having a nice set of automated tests in your project has lots of well publicized advantages. However, if you want to use the tests to help analyze a performance issue you get stuck with a simple problem, how do I run the test and run the Performance Analyzer?
The trick is that the Visual Studio Test project is itself a console application, but it is a sort of headless console application. This isn’t helpful has Performance Analyzer wants you to set a start-up project and without being able to write some code to invoke your tests you’re stuck. Normally a console application will have Project.cs file but test projects automatically build this behind the scenes. This means that if you simply drop a new Project.cs file into your test project it won’t build because you’ll get errors ‘Program has more than one entry point defined’. To allow your Program.cs file to be used you need to edit the project and add the following line after the TargetFramework property item;
Now your test project will have an easy to use Console/Main/Program.cs that you can code to invoke your tests. All you have to do now is point Performance Analyzer at it and press Start.