tags:

views:

50

answers:

2

I have the following task in my nant script:

<nunit2 verbose="true">
            <formatter type="Plain" />
            <test assemblyname="${output}\Test.dll" appconfig="${project.src.root}\Test\Test.config"/>
</nunit2>

Test.config is the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
        <bindingRedirect oldVersion="2.5.3.9345" newVersion="2.2.8.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

I get an error when i run this task saying could not load nunit.framework. I know nunit is not in the GAC (not strongly signed). Does Nunit have to be in the GAC for this task to work?

A: 

You get this error when CALLING unit tests, or when COMPILING unit tests?

Duncan
This question is all about calling NUnit from a NAnt script using the <nunit2> script task.
Programming Hero
A: 

I provide the path to my NUnit binary during compilation. When I call nunit2, the reference to the framework is present and I don't get this error. Does this help?

<target name="unit.compile" depends="sharedClasses, helpers.compile" description="compiles the unit tests" >
    <copy todir="build" flatten="true">
        <fileset basedir="tools\NUnit-2.5.2.9222\framework">
            <include name="nunit.framework.dll" />
        </fileset>
    </copy>

    <csc target="library" output="build\${project::get-name()}.test.unit.dll" debug="${debug}">
        <sources>
            <include name="source\web\tests\unit\**\*.cs" />
            <exclude name="source\web\tests\unit\**\AssemblyInfo.cs" />
        </sources>

        <references basedir="build" >
            <include name="nunit.framework.dll" />
            <include name="Microsoft.Practices.EnterpriseLibrary.Common.dll" />
            <include name="Microsoft.Practices.EnterpriseLibrary.Data.dll" />
            <include name="${project::get-name()}.sharedClasses.dll" />
            <include name="${project::get-name()}.test.helpers.dll" />
        </references>
    </csc>
</target>
<target name="unit.test" depends="unit.compile, helpers.compile">
    <copy file="configuration\Web.Config"       tofile="build\${project::get-name()}.test.unit.dll.config" />
    <copy file="configuration\ui_list.config"   tofile="build\ui_list.test.config" />

    <nunit2>
        <test
            assemblyname="build\${project::get-name()}.test.unit.dll" 
               appconfig="build\${project::get-name()}.test.unit.dll.config"
        />
        <formatter type="Plain" />
    </nunit2>
</target>
Duncan