Boo is groovy two
As I’ve previously written about, developer testing with Boo can facilitate authoring tests quicker due to Boo’s relaxed hip Python-like syntax. Boo also integrates nicely with NAnt, meaning that tests written in Boo can easily be plugged into an automated build system that:
- compiles Boo code into a normal .NET assembly
- runs the corresponding NUnit tests
- reports the results
Compiling copasetic Boo code involves a bit a magic at this point as the current release doesn’t play well with the latest version of NAnt; therefore, in order to get things working properly, I had to use an older version of Boo (0.7.5) and NAnt 0.85-rc2. Once I had the correct versions, things moved quickly from there.
First, I had to load the Boo NAnt tasks with NAnt’s loadtasks task:
<target name="init">
<loadtasks assembly="C:\\dev\\tools\\boo.0.7.5\\bin\\Boo.NAnt.Tasks.dll" />
</target>
Next, the booc task complies all Boo files into a .dll- in my case, I had to reference some additional love power libraries. For instance, I had to reference some .NET system libraries, which I would have figured the .NET runtime would have figured out (I’ve never had to reference a Java system library (rt.jar) when compiling Java or any of its manifold supported languages).
<target name="build" depends="init, setup">
<booc target="library" output="${build.dir}/boo.words.dll">
<sources basedir="src">
<include name="**/*.boo" />
</sources>
<references basedir="./bin">
<include name="nunit.framework.dll" />
<include name="NDbUnit.Core.dll" />
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
</references>
</booc>
</target>
Lastly, once things are compiled, the test target runs the compiled NUnit tests. Note, for some reason, the NDbUnit assembly must be in same directory where the compiled assembly resides in order to the tests to properly run.
<target name="test" depends="build">
<copy todir="${build.dir}">
<fileset basedir="./bin">
<include name="NDbUnit.Core.dll" />
</fileset>
</copy>
<nunit2 failonerror="false">
<formatter type="Xml" usefile="true"
extension=".xml"
outputdir="${build.dir}/results/" />
<test assemblyname="${build.dir}/boo.words.dll"
appconfig="mydefaulttest.config"/>
</nunit2>
</target>
Boo’s smokin’ integration with .NET (and NAnt) makes this a compelling platform for building tests rapidly. Dig it?
| Related odds and ends | ||
|---|---|---|
Thursday 15 Jun 2006 | Boo, Dynamic Languages
[...] The Disco Blog » Boo is groovy two (tags: boo .net) [...]