Using NCover and NUnit with NAnt for .NET 2.0

I had posted previously about getting NCover to work. That time it was while using msbuild. Last night I was trying to get NCover working with NAnt  and NUnit for a different project. Again, I experienced the frustration of getting it working. This sample is using NAnt 0.85-nightly-2006-04-30, NUnit 2.2.7, and NCover 1.5.4beta binaries.
 

<target name="test.with.coverage" depends="build.projects">

    <

copy todir="${build.dir}">

        <

fileset basedir="${tools.nunit.dir}">

            <

include name="nunit.framework.dll"/>

        </

fileset>

    </

copy>

    <copy todir="${build.dir}">

        <

fileset basedir="${tools.ncover.dir}">

            <include name="CoverLib.dll"/>

            <include name="DbgHelp.dll"/>

            <

include name="MSVCP80.dll"/>

            <

include name="MSVCR80.dll"/>

            <

include name="NCover.Console.exe"/>

            <

include name="NCover.Console.exe.config"/>

            <

include name="NCover.Framework.dll"/>

            <

include name="VC80CRT.MAN"/>

        </

fileset>

    </

copy>

    <

copy todir="${build.dir}${results.dir}">

        <

fileset basedir="${tools.ncover.dir}">

            <

include name="Coverage.Xsl"/>

        </

fileset>

    </

copy>

    <

exec basedir="${build.dir}" workingdir="${build.dir}" program="NCover.Console.exe"

        failonerror="true"

        commandline=" ../${tools.nunit.dir}/nunit-console.exe 

            ${project.name}.Test.dll /xml:${results.dir}/test-results.xml /noshadow

            //a ${project.name}.ProjectAssembly; //l ${results.dir}Coverage.log

            //x ${results.dir}ncover-results.xml" />

</target>

 

One thing to note, as mentioned in my previous post, if you haven’t installed NCover, you will need to add a registration step for the CoverLib.dll (regsvr32 /i CoverLib.dll). I installed NCover so that it would work with TestDriven.Net‘s Test with Coverage feature.

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s