c# - <nunit2> 工作不正常

标签 c# nant

我的 nant 脚本中有以下任务:

<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 才能完成这项任务?

最佳答案

我在编译期间提供了我的 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>

关于c# - <nunit2> 工作不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2487386/

相关文章:

nant - NAnt 还在积极开发中吗?

build-process - 是否有针对 .NET 应用程序的预制持续集成解决方案?

rest - TeamCity Nant REST 身份验证

c# - 如何将焦点设置到 WPF 工具包数据网格的特定单元格

c# - 生成的表与 rowspan 导致额外的单元格

c# - List<> 按对象属性排序

c# - 序列化一个可为空的 int

.net - 在项目升级到VS2010后生成程序集信息时,NAnt错误

.NET 项目使用 NAnt/MSBuild + SVN 构建自动化

c# - formview ASP.NET C# 中的验证控件问题