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.
There is a CodePlex project containing an updated source code along with a couple of other useful Msbuild tasks. Here's the link