Page 1 of 1

profile unit test from visual studio

Posted: Mon Jan 17, 2011 11:52 am
by aboute
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.

Re: profile unit test from visual studio

Posted: Mon Jan 17, 2011 10:16 pm
by Andreas Suurkuusk
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.