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

[code language=XML]

       <!-- Finds test DLL's -->

      <CreateItem Include="$(ProjectDirectory)/**/bin/debug/*.Test.dll">
        <Output TaskParameter="Include" ItemName="TestFiles"/>
      </CreateItem>

      <!-- Runs Tests -->

      <Gallio IgnoreFailures="true" Files="@(TestFiles)">
        <Output TaskParameter="ExitCode" PropertyName="ExitCode" />
      </Gallio>

      <Error Text="Tests execution failed" Condition=" '$(ExitCode)' != 0 And '@(TestFiles)' != '' " />

[/code]

BuildAndTest.msbuild (3.32 kb)

blog comments powered by Disqus

About the author

You have probably figured out by now that my name is Bryan Avery (if not, please refer to your browser's address field).  Technology is more than a career to me - it is both a hobby and a passion.  I'm an ASP.NET/C# Developer at heart...

Month List