Sunday 15 August 2010

Running all Tests in Solution

MsTest is a nice testing framework. However it can be annoying from time to time. a while ago in the past I’ve blogged about the inability of this testing framework to execute all tests in a given sln file.
Recently i had some time and I decided thats its about time that ill do something productive about this (instead of my usual complaining) and I’ve sat down to write a simple msbuild task that runs all tests in a solution.
here is an example of a build script that uses this task:

<UsingTask
 TaskName="RunAllTestsInSolution"
 AssemblyFile="RunAllTestsInSolution.dll" />

<PropertyGroup >
 <MSTestLocation>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE</MSTestLocation>
</PropertyGroup>

<Target Name="UnitTestsWithCoverage">
 <RunAllTestsInSolution
   MSTest ="$(MSTestLocation)\mstest.exe"
   SolutionFile="Example.sln"
   Parmaters ="/resultsfile:TestResults.trx" />
</Target>
As you can see you just tells it which mstest version to use, the solution file containing the test you want to execute and any additional parameters if needed.

You can download the source code from here.

*UPDATE*
There is a CodePlex project containing an updated source code along with a couple of  other useful Msbuild tasks. Here's the link

3 comments:

Unknown said...

link to source is down...

Lior Friedman: said...

Hi,

thank you for letting me know.
I've added a new link to Codeplex. the code can be found there.

Anonymous said...

CodePlex is dead. How about Github or some place like that? I would love to have this code. TIA!

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Walgreens Printable Coupons