Home > Machine.Specifications, NAnt, Unit Testing > Using Machine.Specifications with nant

Using Machine.Specifications with nant

Wasted at least an hour today trying to track down an issue running my specs with NAnt. Turns out the problem was using <arg value=”{assembly1} {assembly 2}”  instead of <arg line=”{assembly1} {assembly2}” />.

The subtle difference between value and line is that value allows spaces and presents this to the exe as one argument by quoting the content of the attribute, whereas line passes the content of the attribute as it appears ( so the console runner sees 1 arg in the form “{assembly1} {assembly2}” instead of 2 separate args).  This problem presents itself as an error containing the following text :

Missing Assembly: {assembly1} {assembly2}

The xml for running machine.specifications with NAnt is:

    <target name="test.mspec" unless="${test.skip}">
        <mkdir dir="${test.specreportdir}" />
        <exec program="${test.mspecrunner}"
            basedir="${test.mspecdir}"
            workingdir="${root.dir}">
            <arg value="--silent" if="${teamcity.build}" />
            <arg value="--teamcity" if="${teamcity.build}" />
            <arg value="--html" /><arg dir="${test.specreportdir}" />
            <arg line="${test.assemblies}"/>
        </exec>
    </target>

where:

  • ${test.specreportdir} is the directory for the reports to go into
  • ${test.mspecrunner} is machine.specifications.consolerunner.exe
  • ${test.mspecdir} is the directory containing the mspec console runner
  • ${root.dir} is the root project directory
  • ${teamcity.build} is set from a team city specific build that is used for TC builds
  • ${test.assemblies} is a list of the assemblies containing specs separated by spaces
Advertisement
  1. October 21, 2009 at 6:00 am | #1

    Nice, good work. I wonder what if there’s a way I could detect that and split the assemblies. My only question would be what it does to quotes within the quotes… hmm…

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.