2010-03-21 44 views
2

我在我的惡性腳本以下任務:<nunit2>工作不正常

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

Test.config如下:

<?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> 

我得到一個錯誤,當我運行這個任務說可能不加載nunit.framework。我知道nunit不在GAC中(未簽名)。 Nunit是否必須在GAC中完成此任務?

+0

NUnit無需在GAC中工作。 – 2012-07-31 18:21:21

回答

0

我在編譯期間提供了NUnit二進制文件的路徑。當我調用nunit2時,對框架的引用存在,我不會得到這個錯誤。這有幫助嗎?

<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> 
0

設置你的南特任務,詳細輸出顯示(通常這意味着只需添加「冗長=真正的」適用的任務),看看你是否可以驗證它試圖使用引用nunit.framework路徑.dll文件。

當您試圖通過命令行從NAnt運行任務時,您項目中的nunit.framework.dll路徑很可能是相對路徑,可能無法正常工作。 (例如,如果您的.csproj嵌套在文件夾中,但是您的Nant腳本不是,或者如果您在測試之前移動了構建輸出)。