Universal NAnt Script for Gallio

So Gallio has been out for a little while and I admit that I am a little slow when it comes to looking at new frameworks. I mean there is so much to look at and only so much time in the day allocated to programming. Anyway, there really isn’t much documentation out there yet for using Gallio with NAnt. I am of the thought that is due to all of the people who are really smart with builds are using Rake and/or PSake now. So I set off to create another universal script. This basically follows the conventions from my post with MbUnit’s Universal script and how I added MbUnit2 category filters to it’s NAnt task in UppercuT.

So like I said, Gallio has been out for a little while. This is the first time I have heard that it has underwent some optimizations so now seems a good time to check it out. Until I figure out how to do it another way, this script requires Gallio to be installed on each machine that is going to use it. I am currently trying to figure out how I can get a reduced set of Gallio into source control. The install is 26.4MB right now and that’s bigger than I want my repositories to have to be just for adding a testing framework.

NAnt Script for Gallio

<?xml version="1.0" encoding="utf-8" ?>
<project name="GallioTestRunner" default="go">
  <!-- Project UppercuT - http://projectuppercut.org -->
  <!-- DO NOT EDIT THIS FILE - This follows a convention for testing with Integration tests being separated from Unit tests - find out more at http://uppercut.pbwiki.com -->
  <property name="build.config.settings" value="__NONE__" overwrite="false" />
  <include buildfile="${build.config.settings}" if="${file::exists(build.config.settings)}" />
  <property name="dirs.build" value="${directory::get-parent-directory(project::get-buildfile-path())}\..\..\build_output" />
  <property name="dirs.build_artifacts" value="${dirs.build}\build_artifacts" overwrite="false" />
  <property name="dirs.test_results" value="${dirs.build_artifacts}\gallio" overwrite="false" />
  <property name="file.test_results" value="gallio-results" overwrite="false" />
  <property name="time.limit.in.seconds" value="240" />  <!-- 4 minutes -->
 
  <target name="go" depends="cleanup, run_tests" description="Tests" />
 
  <target name="cleanup">
    <echo message="Removing and adding ${dirs.test_results}."/>
    <delete dir="${dirs.test_results}" failonerror="false" />
    <mkdir dir="${dirs.test_results}" />
  </target>
 
  <target name="load_tasks">
    <echo message="Loading Gallio Nant Tasks from Program Files." />
    <loadtasks assembly="C:\Program Files (x86)\Gallio\bin\Gallio.NAntTasks.dll" if="${file::exists('C:\Program Files (x86)\Gallio\bin\Gallio.NAntTasks.dll')}" />
    <loadtasks assembly="C:\Program Files\Gallio\bin\Gallio.NAntTasks.dll" if="${file::exists('C:\Program Files\Gallio\bin\Gallio.NAntTasks.dll')}" />
  </target>
  
  <target name="run_tests" depends="cleanup,load_tasks" description="Running Unit Tests">
    <echo message="Running tests using Gallio and putting results in ${dirs.test_results}."/>
    <gallio working-directory="${dirs.build}"
            report-types="Html;Xml;Text"
            report-directory="${dirs.test_results}"
            report-name-format="${file.test_results}"
            show-reports="false"
            failonerror="true"
            verbosity="Normal"
            echo-results="true"
            run-time-limit="${time.limit.in.seconds}"
            filter="exclude Category:Database or Category:Integration or Category:Slow or Category:NotWorking or Categroy:Ignore or Category:database or Category:integration or Category:slow or Category:notworking or Categroy:ignore"
            >
      <files>
        <exclude name="${dirs.build}\*Database*dll" />
        <exclude name="${dirs.build}\*.Integration*dll" />
        <exclude name="${dirs.build}\TestFu.dll" />
        <include name="${dirs.build}\*Test*dll" />
        <include name="${dirs.build}\*.Specs*dll" />
      </files>
    </gallio>
  </target>
 
  <target name="run_all_tests" depends="cleanup,load_tasks" description="Running All Unit Tests">
    <echo message="Running all tests (including integration tests) using Gallio and putting results in ${dirs.test_results}."/>
    <gallio working-directory="${dirs.build}"
            report-types="Html;Xml;Text"
            report-directory="${dirs.test_results}"
            report-name-format="${file.test_results}"
            show-reports="false"
            failonerror="true"
            verbosity="Normal"
            echo-results="true"
            run-time-limit="${time.limit.in.seconds}"
            >
      <files>
        <exclude name="${dirs.build}\TestFu.dll" />
        <include name="${dirs.build}\*Test*dll" />
        <include name="${dirs.build}\*.Specs*dll" />
      </files>
    </gallio>
  </target>
 
  <target name="open_results">
    <echo message="Opening results at ${path::get-full-path(dirs.test_results)}\${file.test_results}.html."/>
    <exec
      spawn="true"
      program="${environment::get-folder-path('ProgramFiles')}\Internet Explorer\iexplore.exe"
      commandline="${path::get-full-path(dirs.test_results)}\${file.test_results}.html"
      >
    </exec>
  </target>
 
</project>

UppercuT and Gallio

UppercuT now has support for Gallio baked in. What that means is that you select gallio as your test framework in the config file. Install Gallio. And you’re done. And when you run test from the command line, you get this in your browser:

image

What pretty reports you get from Gallio!

With this knowledge, you shall build.

kick it on DotNetKicks.com

Print | posted @ Sunday, September 20, 2009 10:37 AM

Comments on this entry:

Comments are closed.

Comments have been closed on this topic.