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.

0 comments:

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