Tag Archives: MSBuild

Running Gallio tests using MSBuild

When using a Continuous Integration server such as TeamCity, you’ll need to be able to perform the ability to run tests, the easiest and most controlled way is by writing your own MSBuild Script.

Here is a little build script that finds all the test files and then runs them using Gallio, of course you need to reference the Gallio MSBuildTasks, in my case they are in C:\Program Files\Gallio\bin\Gallio.MsBuildTasks.dll

<p>&nbsp;&nbsp; &nbsp; &nbsp; &lt;!-- Finds test DLL's --&gt;</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp;&lt;CreateItem Include="$(ProjectDirectory)/**/bin/debug/*.Test.dll"&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;Output TaskParameter="Include" ItemName="TestFiles"/&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp;&lt;/CreateItem&gt;</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp;&lt;!-- Runs Tests --&gt;</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp;&lt;Gallio IgnoreFailures="true" Files="@(TestFiles)"&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;Output TaskParameter="ExitCode" PropertyName="ExitCode" /&gt;<br />&nbsp;&nbsp; &nbsp; &nbsp;&lt;/Gallio&gt;</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp;&lt;Error Text="Tests execution failed" Condition=" '$(ExitCode)' != 0 And '@(TestFiles)' != '' " /&gt;</p>

BuildAndTest.msbuild (3.32 kb)