1

In our continuous integration setup, I would like to set up CruisControl.NET to automatically run all our unittests. However, I don't want to have to specify every unittest dll seperately in the configuration.

All the unittest projects are all postfixed with .Test (and all non-unittest projects are not). How can I configure CruiseControl.NET to run all the unittests from these projects (I am using v1.5.7256.1 of CruiseControl.NET)?

My current config attempt:

<nunit>
    <path>$(nunit.path)</path>
    <assemblies>
        <assembly>$(working.dir)\**\*.Test.dll</assembly>
    </assemblies>
</nunit>

I'm finding it very difficult to find documentation on this specific nunit element. Most pages I can find talk about using exec, nunit2 or another nunit element or the nunit-console commandline options.

I don't have much experience with managing the build environment and am working on an existing configuration where every assembly was specified separately in the following manner.

<nunit>
    <path>$(nunit.path)</path>
    <assemblies>
        <assembly>$(artifact.dir)\test1.dll</assembly>
        <assembly>$(artifact.dir)\test2.dll</assembly>
    </assemblies>
</nunit>

Hence my failed attempt using wild cards.

EDIT:

Here is some extra xml of my configuration file to show the context a little bit:

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
    <project name="MyProject">
        <!-- whole bunch of other elements -->
        <tasks>
            <nunit>
                <!-- see above -->
            </nunit>
        </tasks>
    </project>
</cruiscontrol>

After Mightmuke's suggestion, I tried replacing the <nunit> element with his suggestion, but got the following exception: Unable to instantiate CruiseControl projects from configuration document. Configuration document is likely missing Xml nodes required for properly populating CruiseControl configuration. Unable to load array item 'property' - Cannot convert from type System.String to ThoughtWorks.CruiseControl.Core.ITask for object with value: ""

Then I tried to move the <property> and <foreach> element outside the element. Then I get the exception: Unused node detected: <property name="nunit.filelist" value="" />

I'm now trying to find out more about the <foreach> element and where I can put that, but somehow I find it hard to find any documentation about it.

EDIT2:

I found the documentation of the nunit task I'm using: http://ccnet.sourceforge.net/CCNET/NUnit%20Task.html

I specifies the element to be of type String[]. I'm not sure what that means... but it seems from the example that it just means that it must contain a list of child elements of the same name in Singular form.


PS: I realize this question is getting a bit out of hand... When the whole thing is solved, I'll try to edit it in such a format so that it might be useful to someone else later.

Matthijs Wessels
  • 6,530
  • 8
  • 60
  • 103
  • Probably not what you ant to hear, but the nunit task is deprecated in favour of the nunit2 task. However I would recommend that you use the nunit console command line options with the latest version of nunit, and pass in a filtered filelist as an argument. If this is an option for you, I could provide an example. – Mightymuke Jan 21 '13 at 20:56
  • @Mightymuke This _is_ an option for me. I would really appreciate the example. I was wondering though, the deprecated [nunit task](http://nant.sourceforge.net/nightly/latest/help/tasks/nunit.html) seems to have a different api than the one I'm using. I don't see the and element explained there. Am I looking at the wrong documentation? – Matthijs Wessels Jan 22 '13 at 14:35
  • Are you using the [nauckit nant task](http://dev.nauck-it.de/projects/utilities/wiki/NAntTasksNunitTest)? If so, you could potentially use the [AssemblyFileSet](http://nant.sourceforge.net/release/latest/help/types/assemblyfileset.html), but my preference would still be the nunit console option. – Mightymuke Jan 22 '13 at 18:05

1 Answers1

1

This is an example configuration if you were to use the nunit console.

<property name="nunit.filelist" value="" />
<foreach item="File" property="testfile" verbose="true">
  <in>
    <items basedir=".">
      <include name="${working.dir}\**\*.Test.dll" />
    </items>
  </in>
  <do>
    <property name="nunit.filelist" value="${nunitfile.list + ' ' + testfile}" />
  </do>
</foreach>

<exec program="nunit-console-x86.exe" failonerror="true" verbose="true">
  <arg value="${nunit.filelist}" />
  <arg value="/xml=nunit-results.xml" />
  <arg value="/nologo" />
  <arg value="/nodots" />
</exec>

This hasn't been tested, and there are likely better ways to skin it, but it will hopefully provide a starting point for you.

Mightymuke
  • 5,094
  • 2
  • 31
  • 42
  • I will try this and report back. – Matthijs Wessels Jan 24 '13 at 08:02
  • Sorry for the delay, it's been a bit hectic. I replaced my xml with yours, but it doesn't seem to match 1-to-1. I get the following exception: `Unable to instantiate CruiseControl projects from configuration document. Configuration document is likely missing Xml nodes required for properly populating CruiseControl configuration. Unable to load array item 'property' - Cannot convert from type System.String to ThoughtWorks.CruiseControl.Core.ITask for object with value: ""`. This xml is within the `` element. – Matthijs Wessels Jan 30 '13 at 15:42
  • I also tried to move the `` and `` element outside the `` element. Then I get the exception: `Unused node detected: `. I'm going to continue to try to get this right and I'll report back once I get it right. – Matthijs Wessels Jan 30 '13 at 15:45
  • Ahhh, sorry, that was for a nant script (I assumed you posted a nant snippet based on the links you had included). You could still do this by calling a [nant task](http://www.cruisecontrolnet.org/projects/ccnet/wiki/NAnt_Task), but I'll also take a look to see if I've done something similar with a ccnet task. – Mightymuke Jan 30 '13 at 17:50
  • Sorry for not being very clear on that, but I'm not sure how to tell the different within my build config file between those. I suspected I was messing up two different languages because I couldn't find the correct documentation. – Matthijs Wessels Jan 30 '13 at 20:25
  • 2
    You can probably think of NAnt as being like a simple scripting engine and the ccnet build config file as simply configuring plugin's. Not 100% accurate, but close enough. I tend to do all the heavy lifting in NAnt script, and simply plug them into cc.net. [This documentation](http://buildrelease.googlecode.com/hg-history/544994852d33afc460634c972c7c82d510e698e7/Trunk/BreBooks/Expert.NET.Delivery.Using.NAnt.and.CruiseControl.NET.pdf) appears to be fairly comprehensive (although slightly outdated). – Mightymuke Jan 30 '13 at 20:56