profile unit test from visual studio

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
aboute
Posts: 1
Joined: Mon Jan 17, 2011 11:44 am

profile unit test from visual studio

Post by aboute » Mon Jan 17, 2011 11:52 am

I would like to know if it is possible to execute unit tests with MSTest from visual studio (not from the console) that can do this kind of assertion:

Assert.IsTrue(MemProfiler.IsProfiling, "isprofiling");
MemAssertion.NoNewInstances(snapShot);
We are under VS 2010, Window64 bits.

Thanks a lot and best regards,
Anne-Lise Boute.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: profile unit test from visual studio

Post by Andreas Suurkuusk » Mon Jan 17, 2011 10:16 pm

It is currently not possible to profile tests using the "Test->Run" command in Visual Studio, since the test framework (MSTest) must be run under the profiler in order for the memory assertions to work. You can start the tests using the "Profile application" command and select "mstest" as the executable. For more information about this approach, see this thread.

The thread mentions that the new attach API in .NET Framework 4.0 should make it possible to attach to a process and perform assertions. However, this has not been implemented yet, and due to limitation in the attach API, I'm not sure that we will implement it either. What we will try to implement is to add new commands like "Test->Profile->..." which will run the tests under the profiler. But this will likely not be included until version 4.1.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 24 guests